Clojurians
# test-check

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

danstone 17:09:19

I want to write a generator that zipmaps values in coll-a to values in coll-b, but with the restriction that each entry in coll-a will be present in keys of the resulting map. Is this possible?

danstone 17:17:02

I've got something like this
(let [a [1 2 3] b [:foo :bar]] (gen/fmap (partial apply zipmap) (gen/tuple (gen/shuffle a) (gen/return (cycle b)))))

danstone 17:17:18

not sure if there is a better way to do it

gfredericks 18:10:47

how about (let [a [1 2 3], b [:foo :bar]] (gen/let [vals (gen/vector (gen/elements b) (count a))] (zipmap a vals))) @danstone

danstone 18:17:03

Thats great - thanks @gfredericks