As of version 11.1, one can create successive steps of such objects as the Cantor ternary set and a Menger carpet (aka Sierpinski carpet) directly. For example:
CantorMesh /@ Range[0, 2]
(Aside: To create a suitable image to insert here, the code I actually used was
GraphicsColumn[
CantorMesh[#, MeshCellStyle -> {Thick, Red}] & /@ Range[0, 2], AspectRatio -> 0.25]
.)
What I would like, instead of the several mesh pictures, are Boolean indicators of which sections of the original interval and, at each step, its subintervals, are retained and which are deleted. That is, I want to obtain the output:
{{1}, {1, 0, 1}, {1, 0, 1, 0, 0, 0, 1, 0, 1}}
That is easy to do by using the built-in function SubstitutionSystem
:
SubstitutionSystem[{1 -> {1, 0, 1}, 0 -> {0, 0, 0}}, 1, 2]
Or, going back to more basic functions, by:
cStep[lis_] := Flatten[lis /. {1 -> {1, 0, 1}, 0 -> {0, 0, 0}}]
NestList[cStep, {1}, 2]
Question Is there a way to extract the same binary information directly from the result of CantorMesh
?
And similarly for higher-level steps of the Cantor set and for the steps of forming the Menger carpet?