我正在尝试在rextester.com处运行此Lisp代码:
;gnu clisp 2.49
(defun sentence () (append (Noun-phrase) (Verb-phrase)))
(defun Noun-phrase () (append (Article) (Noun)))
(defun Verb-phrase () (append (Verb) (Noun-phrase)))
(defun Article() (one-of '(the a)))
(defun Noun () (one-of '(man ball)))
(defun Verb () (one-of '(run hit took saw)))
(defun one-of (set)
"Pick one element of set, and make a list of it"
(list (random-elt set)))
(defun random-elt (choices)
"Choose an element at a list at random"
(elt choices (random (length choices))))
(sentence)
它执行但不打印任何内容。
另请参见original tutorial。