# Lévy C curve fractal from a substitution systems in NKS book p.190?

How can I make the geometrical transformation described in the page 190 in the New Kind of Science book by Stephen Wolfram to produce the fractal pattern?

https://www.wolframscience.com/nks/p190--substitution-systems-and-fractals

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. Oct 18, 2020 at 20:29

That page has a few links at the end, one called "Implementation [of geometric substitution systems]"

https://www.wolframscience.com/nks/notes-5-4--implementation-of-geometric-substitution-systems

It suggest a very simple implementation via complex numbers. The WL code there can be used in the following way:

f[z_]:=1/2 (1-I) {I z+1/2,z-1/2}
data[n_]:=Nest[Flatten[N@f[#]]&,{0},n];
ComplexListPlot[data[15],PlotTheme->"Detailed"]


You can also use so called AffineTransform and iterated function system (IFS) to build patter more closely to the visual rules. Define:

TransformIFS[g_,IFS[l_List]]:=
t=Table[GeometricTransformation[prim,l[[i]]],{i,Length[l]}];h[t]];

TransformIFS[g_,ifs_IFS,0]:=g;
TransformIFS[g_,ifs_IFS,1]:=TransformIFS[g,ifs];
TransformIFS[g_,ifs_IFS,n_Integer?Positive] :=
TransformIFS[TransformIFS[g,ifs],ifs,n-1];

HeighwayDragon=IFS[{
AffineTransform[{{{1/2, -1/2},{1/2,1/2}},{1,1}/4}],
AffineTransform[{-{{-1/2, -1/2},{1/2,-1/2}},{1,1}/4}]}];

Table[TransformIFS[Graphics[Rectangle[]],HeighwayDragon,n],{n,0,11}]


Another beautiful way of making Lévy C curve fractal from a substitution system is considering representation of substitution systems by paths:

https://www.wolframscience.com/nks/notes-3-5--representation-of-substitution-systems-by-paths

Graphics[Line[AnglePath[(-1)^# Pi/2]]]&@
Last[SubstitutionSystem[{0->{0,0,1},1->{1}},{0},14]]