Created
June 17, 2013 12:48
-
-
Save tgk/5796601 to your computer and use it in GitHub Desktop.
Generate splits over a sequence in Clojure on lazy sequences. Drops last split at the moment.
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 splits | |
[s] | |
(take-while | |
(comp seq second) | |
(iterate | |
(fn [[prefix suffix]] | |
[(conj prefix (first suffix)) | |
(rest suffix)]) | |
[[] s]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment