-
-
Save aeriksson/b6f5e29a1e55fe83aa18 to your computer and use it in GitHub Desktop.
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 partition-subsequent [xs] | |
(let [change-pts (map #(not= (inc %1) %2) (cons (dec (first xs)) xs) xs) | |
indices (filter identity (map-indexed (fn [i x] (if x i)) change-pts))] | |
(map (partial subvec xs) | |
(cons 0 indices) | |
(conj (vec indices) (count xs))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment