Fork me on GitHub

Is there a better way to write this?

(gen/fmap (partial reduce merge)
                            (gen/let [id gen/uuid
                                      x  (gen/hash-map :name gen/string)]
                              {id (assoc x :id id)})))
That is, generate maps where the key is the same as the :id in the map in the value. That works fine and doesn't seem too bad to me — just wondering.


if it were me I would be using plumbing and so I'd have this function around to make it slightly cleaner:


so it becomes (gen/fmap #(map-from-vals :id %) (gen/vector gen-a-map-with-an-id))


which I guess means it also seems natural to me to pull out the map generator and give it a name