Skip to content

Instantly share code, notes, and snippets.

@geekyvin
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekyvin/7ac37e68a739d354e80d to your computer and use it in GitHub Desktop.
Save geekyvin/7ac37e68a739d354e80d to your computer and use it in GitHub Desktop.
(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