loops - clojure.lang.Lazysez cannot be cast to clojure.lang.IFn -
hey im making a* search on 8 puzzle , have 2 main questions.
fixed: first clojure.lang.lazysez cannot cast clojure.lang.ifn when run on line in second part of polymorph in loop im not sure why.
here code:
(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 list 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 []) )
tried since post: removing "else" parens around let statement returns nothing fixed removed else parenthesis , changed doseq lazy , wont output in case. ill ask other question seperatly again
some of base cases in a-star return lazy sequences. calling output of a-star function, because of pair of parens around let statements.
Comments
Post a Comment