restart;Helper Functions for Plotter GraphicsThe helper functions up, down, left and right implement a set of functions to realize graphics for plotter grammar. They create a list of tuples (each tuple being a 2D coordinate, i.e. a list of two values) in the global variable points. The created list can be visualized using Maple's plot command. The last coordinate in the list is treated as the current position of the turtle. The function attach adds another point to the end of the list (point and list given as parameters):attach := proc(li, elem)
# eval(li) ist hier wichtig, weil li u.U. als Referenz \303\274bergeben wird
return [ op(eval(li)),elem];
end proc:up := proc()
global points;
points := attach(points, [ points[-1][1], points[-1][2] + 1 ] );
end proc:down := proc()
global points;
points := attach(points, [ points[-1][1], points[-1][2] - 1 ] );
end proc:left := proc()
global points;
points := attach(points, [ points[-1][1] - 1, points[-1][2] ] );
end proc:right := proc()
global points;
points := attach(points, [ points[-1][1] + 1, points[-1][2] ] );
end proc:Plotter-Grammar Algorithm for Iterations of the Hilbert-CurveCompare Section 3.1 and Algorithm 3.1H := proc(depth::nonnegint)
if depth = 0 then return; end if;
A(depth-1); up();
H(depth-1); right();
H(depth-1); down();
B(depth-1);
end proc:A := proc(depth::nonnegint)
if depth = 0 then return; end if;
H(depth-1); right();
A(depth-1); up();
A(depth-1); left();
C(depth-1);
end proc:B := proc(depth::nonnegint)
if depth = 0 then return; end if;
C(depth-1); left();
B(depth-1); down();
B(depth-1); right();
H(depth-1);
end proc:C := proc(depth::nonnegint)
if depth = 0 then return; end if;
B(depth-1); down();
C(depth-1); left();
C(depth-1); up();
A(depth-1);
end proc:Hilbert := proc(depth::nonnegint)
global points;
points :=[[0,0]];
H(depth);
return eval(points);
end proc;plot( Hilbert(4), scaling=CONSTRAINED, thickness=3);LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=