I can find many examples of setting maximum sizes for generators, but how do I generate lists between a min and max length?
A neat property about generators is they are composable, so you can simply compose a generator for the length of your list with a listOfN
generator.
for {
numElems <- Gen.choose(5, 12)
elems <- Gen.listOfN(numElems, elemGenerator)
} yield elems
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With