本文介绍了在clojure中,如何从映射绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定地图:
c>使用 myMap 解决方案作为声明,字符串键的解构看起来像是最好的打赌:(let [{:strs [abcdef]} myMap]
(println abcdef))
; => 1 2 3 4 5 6
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?
解决方案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
这篇关于在clojure中,如何从映射绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!