Skip to content

Instantly share code, notes, and snippets.

@aeriksson
Created July 6, 2015 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aeriksson/b6f5e29a1e55fe83aa18 to your computer and use it in GitHub Desktop.
Save aeriksson/b6f5e29a1e55fe83aa18 to your computer and use it in GitHub Desktop.
(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