Skip to content

Instantly share code, notes, and snippets.

@cninja
Created November 9, 2010 13:36
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 cninja/669075 to your computer and use it in GitHub Desktop.
Save cninja/669075 to your computer and use it in GitHub Desktop.
New distinct?
(defn distinct2
[coll]
(lazy-seq
((fn step [[f :as xs] seen]
(when-let [s (seq xs)]
(if (contains? seen f)
(recur (rest xs) seen)
(cons f (step (rest xs) (conj seen f))))))
coll #{})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment