Last active
August 7, 2016 21:02
-
-
Save atroche/5647270 to your computer and use it in GitHub Desktop.
Comparing different solutions to http://www.4clojure.com/problem/43
This file contains hidden or 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
; my incredibly ugly solution | |
(fn rinter [s parts] | |
(letfn [(mod-index [s n] (keep-indexed (fn [index item] [(rem index n) item]) s))] | |
(map (fn [place] | |
(reduce (fn [acc [index v]] | |
(if (= index place) | |
(conj acc v) | |
acc)) | |
[] | |
(mod-index s parts))) | |
(range parts)))) | |
; daowen's elegant, idiomatic solution | |
#(apply map list (partition %2 %)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment