Skip to content

Instantly share code, notes, and snippets.

@yuriyzubarev
Created September 8, 2012 06:05
Show Gist options
  • Save yuriyzubarev/3672274 to your computer and use it in GitHub Desktop.
Save yuriyzubarev/3672274 to your computer and use it in GitHub Desktop.
Algorithms, Part 1, Union Find
(def l [0 1 2 3 4 5 6 7 8 9])
(defn union-qf[p q l]
(let [pid (nth l p)]
(map #(if (= % pid) (nth l q) %) l)))
(println (union-qf 6 7 (union-qf 2 8 (union-qf 0 5 (union-qf 7 1 (union-qf 4 3 (union-qf 2 3 l)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment