;; Exercise 2.3
(def simple-japanese-grammar
'((sentence -> (subject predicate))
(subject -> (noun-phrase ParticleForSubject))
(predicate -> (noun-phrase ParticleForObject Verb))
(noun-phrase -> (NounModifier Noun))
(NounModifier -> その ある)
(Noun -> 男 ボール 女 テーブル)
(ParticleForSubject -> が)
(ParticleForObject -> を)
(Verb -> 打った 取った 見た 好んだ)))
(reset! grammar simple-japanese-grammar)
(generate 'sentence)
> (generate 'sentence)
(ある テーブル が その 女 を 好んだ)
CL-USER> (defun make-counter (n)
(lambda ()
(incf n)))
MAKE-COUNTER
CL-USER> (defparameter c (make-counter 0))
C
CL-USER> (funcall c)
1
CL-USER> (funcall c)
2
CL-USER> (defparameter c2 (make-counter 0))
C2
CL-USER> (funcall c2)
1