Peano Curve
Vasiliki Liontou 23/12/17

(*To begin with, I construct a function that draws the peano curve in every square of step n.*)

Curve[n_Integer,l_List]:= Graphics[Line[{Scaled[l+{-1/3^n,-1/3^n}],Scaled[l+{-1/3^n,0}], Scaled[l+{-1/3^n,1/3^n}],Scaled[l+{0,1/3^n}],Scaled[l],Scaled[l+{0,-1/3^n}],Scaled[l+{1/3^n,-1/3^n}],Scaled[l+{1/3^n,0}],Scaled[l+{1/3^n,1/3^n}]}],Frame->True,PlotRange->{{0,1},{0,1}}]

Curve[1,{0,0}]

(*Then I create a function that constructs the list of all square centers in step i*)

Centers={};
MakeCenters[i_Integer]:=For[k=0,k≤ i,k++,
For[j=0,j≤ i,j++
AppendTo[Centers, {k/3^i+1/2*3^i,j/3^i+1/2*3^i}]]]
(*Finally, the function Peano[m_Integer] draws the Peano curve for each number 0≤i≤m *)
Peano[m_Integer]:=For[i=0,i≤ m,i++,
MakeCenters[i];
For[p=0,p≤ Length[Centers],p++,
Curve[i,Centers[[p]]]]]