小编Rob*_*own的帖子

将一段Lisp代码移植到Clojure(PAIP)

我正在阅读Peter Norvig 编写的人工智能编程范例(PAIP),我正在尝试用Clojure编写所有代码,而不是使用常见的Lisp编写代码.但是我仍然坚持第39页的这段代码:

(defparameter *simple-grammar*
  '((sentence -> (noun-phrase verb-phrase))
   (noun-phrase -> (Article Noun))
   (verb-phrase -> (Verb noun-phrase))
   (Article -> the a)
   (Noun -> man ball woman table)
   (Verb -> hit took saw liked))
  "A grammar for a trivial subset of English.")

 (defvar *grammar* *simple-grammar*)
Run Code Online (Sandbox Code Playgroud)

我怎样才能把它翻译成Clojure?谢谢.

lisp artificial-intelligence clojure common-lisp

11
推荐指数
2
解决办法
1401
查看次数