Created
March 3, 2012 02:11
-
-
Save thomcc/1963683 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 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