简体   繁体   English

创建哈希图Clojure

[英]Creating Hash-Map Clojure

I have 2 list let say list of user (list-usr) and (usr-index), i want to create hash-map from these list much like 我有2个列表,可以说用户(list-usr)和(usr-index)的列表,我想从这些列表创建哈希映射,就像

(def list-usr [196 186 244])
(def idx-usr  [0 1 2])

how can i form (hash-map {196 0 186 1 244 2}) from 2 list ? 我如何从2个列表中形成(hash-map {196 0 186 1 244 2})

ByanJati ByanJati

The function for taking two vectors and interleaving to create hash map is zipmap . 取两个向量并交织以创建哈希图的功能是zipmap

It should provide what you want, keep in mind that you will be using integers as the keys: 它应该提供所需的内容,请记住,您将使用整数作为键:

(zipmap list-usr idx-usr)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM