Created
May 11, 2010 07:36
-
-
Save tgk/397022 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 converging-seq | |
"Generates a sequence with terminates when two successive elements | |
from coll are identical. | |
(converged-seq [1 2 3 4 4 5 6]) => [1 2 3 4]" | |
[coll] | |
(cons | |
(first coll) | |
(map second | |
(take-while (fn [[prev curr]] (not (= prev curr))) | |
(partition 2 1 coll))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment