Skip to content

Lazy cartesian products #114

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

Merged
merged 7 commits into from
Oct 20, 2023
Merged

Lazy cartesian products #114

merged 7 commits into from
Oct 20, 2023

Conversation

01mf02
Copy link
Owner

@01mf02 01mf02 commented Oct 20, 2023

This PR makes the evaluation of cartesian products lazy in both arguments.

Previously, only the left-hand side of binary filters (such as addition) were evaluated lazily. As a consequence,

limit(3; recurse(.+1) + 0)

would terminate, but

limit(3; 0 + recurse(.+1))

would not. With this PR, both variants terminate.

As a downside, the results of the right-hand side are not cached anymore.
That is, (0, 1) + expensive_f will now evaluate expensive_f twice, whereas it was only evaluated once before.
However, I suppose that the impact of this is minimal, because few people would use multiple inputs in conjunction with "expensive" functions as arguments to binary operators.

@01mf02 01mf02 merged commit d80cd0d into main Oct 20, 2023
@01mf02 01mf02 deleted the lazy-cartesian branch October 20, 2023 08:05
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

Successfully merging this pull request may close these issues.

1 participant