0
嘿即時製作A *搜索八個難題,我有兩個主要問題。clojure.lang.Lazysez不能投到clojure.lang.IFn
FIXED:首先,我是說我就在多晶型的第二部分的線循環運行這個但林不知道爲什麼clojure.lang.Lazysez不能轉換爲clojure.lang.IFn。
這裏是我的代碼:
(defn a-star
([board history]
(if (at-end? board) (println board)
(
(let [options (filter #(possible-move? % board) *moves*)
move (into (pm/priority-map) (for [move options] [move (global-man-dis (move-tile board move))]))]
(for [pair move :let [next-move (key pair)]]
(do
(println (move-tile board next-move))
(a-star (move-tile board next-move) next-move (conj history board))
)
)
)
)))
([board prev-move history]
(if (or (at-end? board) (history-check history board)) (println board)
(
(let [options (get-queue board (dont-go-back prev-move))
move (into (pm/priority-map) (for [move options] [move (global-man-dis (move-tile board move))]))]
(for [pair move :let [next-move (key pair)]]
(do
(println (move-tile board next-move))
(a-star (move-tile board next-move) next-move (conj history board))
)
)
)
))))
(defn -main [& args]
(println "insert a list all numbers no spaces or letters")
(def board (mapv (fn [^Character c] (Character/digit c 10)) (read-line)))
;(def testt [0 8 4 7 2 1 3 5 6])
;(def testt [1 2 3 5 4 6 8 0 7])
(a-star board [])
)
因爲後嘗試:刪除「其他」的括號圍繞讓語句,但現在沒有返回 固定刪除其他括號,並改變以doseq爲懶惰和在這種情況下不會輸出任何東西。生病再次請求另一個問題
即時通訊有點困惑哪些額外的parens?我嘗試刪除整個let上的「else」parens,但它現在不返回任何內容 – user2150839
在repl中看到以下區別:'(let [a(constant true)] a)''((let [a true)] a))'' - 一個返回一個函數,另一個返回true。 – noisesmith
通過沒有返回你的意思是返回零?如果發生這種情況可能是因爲print語句返回nil,並且您使用print語句結束分支。 – noisesmith