Add support for push ('[') and pop (']') operations

This commit is contained in:
Dimitri Lozeve 2018-01-17 10:54:44 +00:00
parent 1b2defc067
commit 05feb56763
4 changed files with 43 additions and 17 deletions

View file

@ -9,6 +9,8 @@ module Examples
, sierpinski
, sierpinskiArrow
, dragon
, tree
, plant
) where
import Lib
@ -90,3 +92,23 @@ dragon = LSystem
90
10
[('F',Forward), ('+',TurnRight), ('-',TurnLeft)]
-- | Binary tree
tree = LSystem
"AB+-[]"
"A"
[('B', "BB")
,('A', "B[+A]-A")]
45
1
[('A',Forward), ('B',Forward), ('+',TurnRight), ('-',TurnLeft), ('[',Push), (']',Pop)]
-- | Fractal plant
plant = LSystem
"FX+-[]"
"X"
[('X', "F[-X][X]F[-X]+FX")
,('F', "FF")]
25
1
[('F',Forward), ('+',TurnRight), ('-',TurnLeft), ('[',Push), (']',Pop)]