spock-genesis
spock-genesis copied to clipboard
permute() does not distinguish between finite and infinite generators
Is there a way to define a map generator that takes permutations of finite value generators, and considers any infiinite value generators in the map as noise, so irrelevant for the permutations?
Here's an example:
def m=map(
noise:integer(1000..2000),
relevant1:any('A','B'),
relevant2:any('C')
)
m.permute().collect()
The resulting collection should contain only 3 elements (the number of permutations of relevant1 and relevant2), for each element, the noise value should be different.
Is there a way to achieve this, or is this bad practice in your opinion?
@LuisMuniz sorry about not getting back to you sooner, I missed the notification. I am sure you figured something out by now but here is an example of doing that:
tuple(
map(relevant1: ['A','B'], relevant2: ['C']).permute(),
map(noise: integer(1000..2000))
).map { data, noise ->
data + noise
}.collect()
Right now infinite generators are allowed in permute but the depth of permutation is allowed. I am sceptical about doing something based on a variant of the method that takes some sort of behavior altering flag when it can be accomplished without too much difficulty. How often do you feel this comes up?