我試圖當試圖從「Lisp的土地」 http://landoflisp.com/wizards_game.lisp重寫精靈遊戲
(def *nodes* {:living-room "you are in the living-room. a wizard is snoring loudly on the couch."
:garden "you are in a beautiful garden. there is a well in front of you."
:attic "you are in the attic. there is a giant welding torch in the corner."})
(def *edges* {:living-room '((garden west door) (attic upstairs ladder))
:garden '(living-room east door)
:attic '(living-room downstairs ladder)})
(defn describe-location [location nodes]
(nodes location))
(defn describe-path-raw [edge]
`(there is a ~(last edge) going ~(second edge) from here.))
(defn describe-path [edge]
(map #(symbol (name %)) (describe-path-raw edge)))
(defn describe-paths [location edges]
(apply concat (map describe-path-raw (location edges))))
改寫精靈遊戲:
(println (describe-paths :attic *edges*))
我得到這個異常:
線程「main」中的異常java.lang.RuntimeException:java.lang.IllegalArgumentException:不知道如何從:cl創建ISeq ojure.lang.Symbol(wizard-game.clj:0)
我還沒有Lispy眼,我做錯了什麼?
+1「Lispy eye」。 – 2012-01-01 00:36:09