Created
November 9, 2010 13:36
-
-
Save cninja/669075 to your computer and use it in GitHub Desktop.
New distinct?
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 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