Fork me on GitHub
#test-check
<
2017-01-16
>
wotbrew15:01: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?

wotbrew15:01: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)))))

wotbrew15:01:18

not sure if there is a better way to do it

gfredericks16:01: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

wotbrew16:01:03

Thats great - thanks @gfredericks