Skip to content

Instantly share code, notes, and snippets.

@kasperlanger
Created May 11, 2010 08:18
Show Gist options
  • Save kasperlanger/397063 to your computer and use it in GitHub Desktop.
Save kasperlanger/397063 to your computer and use it in GitHub Desktop.
(defn converging-seq
[coll]
(for [[x y] (partition 2 1 (cons (gensym) coll)) :while (not (= x y))] y))
(defn converging-seq2
[[x y & tl]]
(cond (nil? x) []
(nil? y) [x]
(= x y) [x]
:else (lazy-seq (cons x (converging-seq2 (cons y tl))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment