Created
August 10, 2015 00:56
-
-
Save thiagomoretto/eebb1120ebca8d245350 to your computer and use it in GitHub Desktop.
Breadth-first
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn bfs [sz ef ff] | |
"Initial state sz, expansion function ef [s] and feasibility function ff [s]" | |
(loop [queue (conj clojure.lang.PersistentQueue/EMPTY sz) | |
ef ef | |
ff ff] | |
(if (seq queue) | |
(let [nx (peek queue)] | |
(if (ff nx) nx (recur (into (pop queue) (ef nx)) ef ff))) | |
nil))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment