Skip to content

Instantly share code, notes, and snippets.

@hoeck
Created October 10, 2010 09:04
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 hoeck/619097 to your computer and use it in GitHub Desktop.
Save hoeck/619097 to your computer and use it in GitHub Desktop.
(reduce #(if (= (peek (peek %)) %2)
(conj (pop %) (conj (peek %) %2))
(conj % [%2]))
[]
[1 1 1 2 2 3 3 3])
@yayitswei
Copy link

Thanks for this solution. Just discovered a function to do this:

(partition-by identity  [1 1 1 2 2 3 3 3])

Feels like cheating :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment