You're viewing version 1.2.0 of zipmap. The latest stable version of Clojure Core is 1.3.0.
1.2.0 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:2296 top

(defn zipmap
  "Returns a map with the keys mapped to the corresponding vals."
  {:added "1.0"}
  [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: and assoc defn first loop map next

Comments top

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