Last active
August 29, 2015 14:20
-
-
Save geekyvin/7ac37e68a739d354e80d to your computer and use it in GitHub Desktop.
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
(def graph {:A {:B 5 :D 5 :E 7} | |
:B {:C 4} | |
:C {:D 8 :E 2} | |
:D {:C 8 :E 6} | |
:E {:B 3} | |
}) | |
(defn looper [g startnode & args] | |
(let [[inode] (vec args) | |
acc []] | |
(if (= startnode inode) | |
(conj acc inode) | |
(conj acc inode (map (partial looper g startnode) (vec (keys (get g inode))))) | |
))) | |
(looper graph :C) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment