bind
function
clojure.test.check.generators/bind
(bind [generator f])Creates a new generator that passes the result of `gen` into function
`f`. `f` should return a new generator. This allows you to create new
generators that depend on the value of other generators. For example,
to create a generator of permutations which first generates a
`num-elements` and then generates a shuffling of `(range num-elements)`:
(gen/bind gen/nat
;; this function takes a value generated by
;; the generator above and returns a new generator
;; which shuffles the collection returned by `range`
(fn [num-elements]
(gen/shuffle (range num-elements))))
Also see gen/let for a macro with similar functionality.
Examples
No examples yet. Be the first to add one!