Skip to content

Instantly share code, notes, and snippets.

@thomcc
Created March 3, 2012 02:11
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 thomcc/1963683 to your computer and use it in GitHub Desktop.
Save thomcc/1963683 to your computer and use it in GitHub Desktop.
(defn splitup [ls]
(loop [rest ls, evens [], odds []]
(if-not rest
[evens odds]
(recur (nnext rest)
(conj evens (first rest))
(if (fnext rest)
(conj odds (fnext rest))
odds)))))
; (splitup (range 10))
; [[0 2 4 6 8] [1 3 5 7 9]]
; (splitup (range 9))
; [[0 2 4 6 8] [1 3 5 7]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment