Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permute() does not distinguish between finite and infinite generators #28

Open
LuisMuniz opened this issue Nov 19, 2016 · 1 comment
Open

Comments

@LuisMuniz
Copy link

LuisMuniz commented Nov 19, 2016

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?

@Bijnagte
Copy link
Owner

Bijnagte commented Jan 7, 2017

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants