⍝ L-systems:

    algae ← ('A' 'AB')('B' 'A')             ⍝ Algae
    algae lsys ⍣7 ⊢'A'                      ⍝ 7th iteration
ABAABABAABAABABAABABAABAABABAABAAB

    pyth ← ('1' '11')('0' '1[0]0')          ⍝ Pythagorus tree
    pyth lsys⍣3 ⊢'0'                        ⍝ 3rd iteration
1111[11[1[0]0]1[0]0]11[1[0]0]1[0]0

    cant ← ('A' 'ABA')('B' 'BBB')           ⍝ Cantor dust
    cant lsys⍣3 ⊢'A'                        ⍝ 3rd iteration
ABABBBABABBBBBBBBBABABBBABA

    koch ← 'F' 'F-F++F-F'                   ⍝ Koch curve
    koch lsys⍣1 ⊢'F++F++F'                  ⍝ 1st iteration
F-F++F-F++F-F++F-F++F-F++F-F

    sier ← ('A' '+B-A-B+')('B' '-A+B+A-')   ⍝ Sierpinski triangle
    sier lsys⍣2 ⊢'A'                        ⍝ 2nd iteration
+-A+B+A--+B-A-B+--A+B+A-+

    drag ← ('X' 'X+YF+')('Y' '-FX-Y')       ⍝ Dragon curve
    drag lsys⍣3 ⊢'FX'                       ⍝ 3rd iteration
FX+YF++-FX-YF++-FX+YF+--FX-YF+

    fern ← ('X' 'F-[[X]+X]+F[+FX]-X')('F' 'FF')     ⍝ Fractal plant
    fern lsys⍣2 ⊢'X'                                ⍝ 2nd iteration
FF-[[F-[[X]+X]+F[+FX]-X]+F-[[X]+X]+F[+FX]-X]+FF[+FFF-[[X]+X]+F[+FX]-X]-F-[[X]+X]+F[+FX]-X

    hilbert ← ('A' '-BF+AFA+FB-')('B' '+AF-BFB-FA+')    ⍝ Hilbert curve
    hilbert lsys⍣2⊢'A'                                  ⍝ 2nd iteration
-+AF-BFB-FA+F+-BF+AFA+FB-F-BF+AFA+FB-+F+AF-BFB-FA+-

⍝∇ lsys

Back to: code

Back to: Workspaces