summaryrefslogtreecommitdiff
path: root/examples/l-system-example.lisp
blob: deac189949075c7461e896573279ea921d4b603f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(in-package #:l-system-examples)

;;Lindenmayer's original L-system
;;Example 1: Algae
(-> a ()
  '((a) (b)))

(-> b ()
  '((a)))

(l-system #'parametric-grammar '((a)) 3)

;;;Parametric grammars
(-> f ()
  '((f 1)
    (j 1)
    (f 1)))

(-> j (x)
  (if (oddp x)
      `((j ,(1+ (* 3 x))))
      `((j ,(/ x 2)))))

(l-system #'parametric-grammar '((f 1.0)) 3)

;;;Context sensitive grammars
(-> (f j f) (x)
  `((j ,(* 2 x))))

(l-system #'context-sensitive-grammar '((f 1.0)) 3)