speculative 2019-01-10

it was fun, lots of good reactions. we wrote a spec for zipmap at the meetup:

(s/fdef clojure.core/zipmap
  :args (s/cat :keys ::ss/seqable
               :vals ::ss/seqable)
  :ret ::ss/map)
But thinking more about it, keys and vals should probably be sequential, since (zipmap #{:a :b :c} [1 2 3]) ;;=> {:c 1, :b 2, :a 3}.

unless there’s a valid use case for not calling it with sequentials

yeah, I think I found one: (zipmap (into-array [:a :b :c]) [1 2 3])

Alex Miller (Clojure team) 2019-01-10T11:36:03.064100Z

a common idiom is to use zipmap with a collection as a set of seed keys for a map and repeat with the initial values

Alex Miller (Clojure team) 2019-01-10T11:36:48.065Z

(def names #{"Alex" "Rich" "Stu"})
(def scores (zipmap names (repeat 0)))
;;=> {"Stu" 0, "Rich" 0, "Alex" 0}

cool, so it should def support seqable? then

I also changed assoc-in and get-in to seqable? instead of sequential? for the key seq

No worries. Hope it went well!