speculative

https://github.com/borkdude/speculative
slipset 2019-01-10T05:43:10.060100Z

No worries. Hope it went well!

borkdude 2019-01-10T08:54:19.061800Z

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}.

borkdude 2019-01-10T08:54:41.062200Z

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

borkdude 2019-01-10T08:55:48.062500Z

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

alexmiller 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

alexmiller 2019-01-10T11:36:48.065Z

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

borkdude 2019-01-10T11:39:41.065800Z

cool, so it should def support seqable? then

borkdude 2019-01-10T11:40:30.067100Z

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

borkdude 2019-01-10T11:42:58.067800Z

will add your example to the tests soon: https://github.com/borkdude/speculative/issues/216#issuecomment-453067231