clojure.lang.Lazysez不能强制转换为clojure.lang.IFn

时间:2013-09-24 18:35:16

标签: loops clojure sequence

嘿我在八个谜题上进行A *搜索,我有两个主要问题。

FIXED :首先我得到clojure.lang.Lazysez不能被强制转换为clojure.lang.IFn当我在for循环中的多边形的第二部分中运行这个但是我不是确定为什么。

这是我的代码:

(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 [])
  )

自帖子后尝试:在let语句中删除“else”parens但现在什么都不返回 FIXED 删除了else括号并更改为doseq,因为它是懒惰的,在这种情况下不会输出任何内容。生病了再次问另一个问题

1 个答案:

答案 0 :(得分:1)

a-star中的一些基本案例返回延迟序列。你将a-star的输出称为函数,因为let语句周围有一对额外的parens。