Skip to content

Instantly share code, notes, and snippets.

@paulosuzart
Forked from rafaelfelini/ltm.clj
Created December 15, 2011 00:14
Show Gist options
  • Save paulosuzart/1479226 to your computer and use it in GitHub Desktop.
Save paulosuzart/1479226 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] {(keyword (first l)) (second l) } ) (partition 2 lst))))
;kudos to @paulosuzart
;user=> (ltm '(:a 1 :b 2 :c3 :d 4))
;{:c3 :d, :b 2, :a 1}
;;or
;;user=> (ltm '("name" "paulo" "age" 29))
;;{:age 29, :name "paulo"}
@rafaelfelini
Copy link

Maybe you can use (keyword (str 1))

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