

Task
Produce a graphical or ASCII-art representation of a Hilbert curve of at least order 3.

100 PROGRAM "Hilbert.bas"
110 OPTION ANGLE DEGREES
120 GRAPHICS HIRES 2
130 LET N=5:LET P=1:LET S=11*2^(6-N)
140 PLOT 940,700,ANGLE 180;
150 CALL HILBERT(S,N,P)
160 DEF HILBERT(S,N,P)
170   IF N=0 THEN EXIT DEF
180   PLOT LEFT 90*P;
190   CALL HILBERT(S,N-1,-P)
200   PLOT FORWARD S;RIGHT 90*P;
210   CALL HILBERT(S,N-1,P)
220   PLOT FORWARD S;
230   CALL HILBERT(S,N-1,P)
240   PLOT RIGHT 90*P;FORWARD S;
250   CALL HILBERT(S,N-1,-P)
260   PLOT LEFT 90*P;
270 END DEF