1.3.0 permalink Arrow_down_16x16

zipmap

clojure.core

  • (zipmap keys vals)
Returns a map with the keys mapped to the corresponding vals.

2 Examples top

  • user=> (zipmap [:a :b :c :d :e] [1 2 3 4 5])
    {:e 5, :d 4, :c 3, :b 2, :a 1}
    
  • ;; 4 is not included in the result
    user=> (zipmap [:a :b :c] [1 2 3 4])
    {:c 3, :b 2, :a 1}
    
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2651 top

(defn zipmap
  "Returns a map with the keys mapped to the corresponding vals."
  {:added "1.0"
   :static true}
  [keys vals]
    (loop [map {}
           ks (seq keys)
           vs (seq vals)]
      (if (and ks vs)
        (recur (assoc map (first ks) (first vs))
               (next ks)
               (next vs))
        map)))
Vars in clojure.core/zipmap:
Used in 0 other vars

Comments top

No comments for zipmap. Log in to add a comment.