句子生成器将不会在线执行

问题描述 投票:0回答:1

我正在尝试在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

common-lisp
1个回答
1
投票

运行正常-您只需要print结果:替换

print

with

(sentence)

您将会看到

(print (sentence))

(尽管(THE BALL TOOK THE MAN) 总是the same!]

© www.soinside.com 2019 - 2024. All rights reserved.