Created
April 5, 2013 18:26
-
-
Save jeremyheiler/5321505 to your computer and use it in GitHub Desktop.
Pointfree!
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
(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]] | |
(reduce (partial apply assoc) {} (map (partial map clojure.string/trim) d))) | |
;=> {"c" "3", "b" "2", "a" "1"} |
saolsen
commented
Apr 5, 2013
well hell, why not do this?
(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]]
(apply assoc {} (map clojure.string/trim (flatten d))))
or this
(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]]
(->> d
flatten
(map clojure.string/trim)
(apply assoc {})))
Slightly better:
(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]]
(apply hash-map (map clojure.string/trim (flatten d))))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment