-
-
Save rafaelfelini/1479212 to your computer and use it in GitHub Desktop.
Makes a clojure Map from a given coll.
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 ltm | |
"Makes a clojure map from a given collection. lst should have an even number of elements" | |
[lst] | |
(reduce merge | |
(map (fn [l] { (first l) (second l) } ) (partition 2 lst)))) | |
;kudos to @paulosuzart | |
;user=> (ltm '(:a 1 :b 2 :c 3 :d 4)) | |
;{:d 4, :c 3, :b 2, :a 1} | |
;user=> (ltm '(1 2 3)) | |
;{1 2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
much better! I kinda addicted to loop recur. :)