ByanJati
ByanJati

Reputation: 83

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

(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 ?

Upvotes: 2

Views: 421

Answers (1)

Frank C.
Frank C.

Reputation: 8088

ByanJati

The function for taking two vectors and interleaving to create hash map is zipmap.

It should provide what you want, keep in mind that you will be using integers as the keys:

(zipmap list-usr idx-usr)

Upvotes: 5

Related Questions