@jfntn one way is using gen/let
:
(defn gen-with-index-and-count-using-let
"Return a generator that will return tuples of:
[<value from coll-gen>
[<valid index in coll>
<count within bounds of index to end of coll>]."
[coll-gen]
(gen/let [coll coll-gen
index (gen/choose 0 (max 0 (dec (count coll))))
bounded-count (gen/choose 0 (- (count coll) index))]
[coll [index bounded-count]]))
makes it much easier to read to my eyes 🙂
Ooh monads 😄 very nice, didn’t know about this let, thank you
Hehe yeah, it's a macro that takes those bindings and transform them to use gen/bind so it's probably generating something similar to your original generator