Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In clojure, how does one bind from a map?

Tags:

clojure

Given the map:

(def myMap {"a" 1 "b" 2 "c" 3 "d" 4 "e" 5 "f" 6})

I wish to use let to bind each key to each value. What is the most concise way to do this?

like image 550
user2179977 Avatar asked Aug 14 '26 21:08

user2179977


1 Answers

with myMap as declared, destructuring of string keys seems like the best bet:

(let [{:strs [a b c d e f]} myMap] 
    (println a b c d e f))
;=> 1 2 3 4 5 6
like image 147
sw1nn Avatar answered Aug 16 '26 16:08

sw1nn