Skip to content

Instantly share code, notes, and snippets.

@rafaelfelini
Forked from paulosuzart/mkhash.clj
Created December 15, 2011 00:09
Show Gist options
  • Save rafaelfelini/1479212 to your computer and use it in GitHub Desktop.
Save rafaelfelini/1479212 to your computer and use it in GitHub Desktop.
Makes a clojure Map from a given coll.
(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}
@paulosuzart
Copy link

much better! I kinda addicted to loop recur. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment