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

Implement lazy cartesian product #11

Closed
xgbuils opened this issue May 14, 2017 · 3 comments
Closed

Implement lazy cartesian product #11

xgbuils opened this issue May 14, 2017 · 3 comments

Comments

@xgbuils
Copy link
Owner

xgbuils commented May 14, 2017

Now, cartesian method does not allow to be used with infinite iterables. If cartesian returns an iterable of iterables, this method will be able to be lazy.

@xgbuils xgbuils added this to the release 2.0 milestone May 14, 2017
@xgbuils
Copy link
Owner Author

xgbuils commented May 15, 2017

Thinking about it, cartesian method implementation is already lazy. This method allows a finite number of iterables. These iterables can be potentially infinite. When I thought in lazy cartesian method, I thought in a product of infinite iterables. However this thing is impossible to implement because we need to know if all of iterables are empty or not to check if the iterable result is empty or not.

Then, I just have to implement cartesian method that returns an Iterum instance of Iterum instances.

@xgbuils
Copy link
Owner Author

xgbuils commented May 16, 2017

However, the current implementation of cartesian returns values in this order:

Iterum([1, 2]).cartesian([3, 4]) /* (
    (1 3)
    (1 4)
    (2 3)
    (2 4)
) */

For consistency, I prefer:

Iterum([1, 2]).cartesian([3, 4]) /* (
    (1 3)
    (2 3)
    (1 4)
    (2 4)
) */

Because there are other methods like permutations, power, combinations, variations that could be work with infinite iterables and numbers if the first value of iterables is that variates first.

@xgbuils
Copy link
Owner Author

xgbuils commented May 20, 2017

I also going to change cartesian method name to product.

xgbuils added a commit that referenced this issue May 20, 2017
@xgbuils xgbuils closed this as completed May 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant