No worries. Hope it went well!
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])
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
(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
will add your example to the tests soon: https://github.com/borkdude/speculative/issues/216#issuecomment-453067231