Using Picolisp 'co routine to...
Generate Gosper-curve states from L-System rules
: (GosperGen T) # Reset
-> T
: (do 64 (prin (GosperGen)))
A-B--B+A++AA+B--+A-BB--B-A++A+B--+A-BB--B-A++A+B+A-B--B+A++AA+B--> "-"
: (GosperGen)
-> "+"
: (GosperGen)
-> "+"
: (GosperGen)
-> "A"
..
A depth of 12 generates about 32GB worth of information...
This uses very little stack and is easily generalized for other L-Systems
to generate rules for 'growing' complex images that can be rendered using
the picolisp canvas drawing lib.
/Lindsay
# A and B mean to move forward
# + means to turn left 60 degrees
# - means to turn right 60 degrees
(de GosperGen (D)
(if (=T D)
(co 'gospergen)
(co 'gospergen
(let
(A (chop "A-B--B+A++AA+B-")
B (chop "+A-BB--B-A++A+B")
_MaxDepth D
_Plot '((L) (mapc yield L))
_Fn
'((X)
(cond
((= X "A") A)
((= X "B") B)
(T (list X)) ) )
_L-Run
'((L D)
(if (>= D _MaxDepth)
(_Plot L)
(mapc
'((X) (_L-Run (_Fn X) (inc D)))
L ) ) ) )
(default _MaxDepth 13)
(_L-Run A 1) ) ) ) )