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

Add combinatorial iterators: product, permutations, combinations, etc. #471

Open
cjquines opened this issue Jan 21, 2024 · 3 comments
Open
Labels
feature request New feature or request help wanted Extra attention is needed

Comments

@cjquines
Copy link
Collaborator

Related, but separate proposals:

@cjquines
Copy link
Collaborator Author

i also definitely have a lot more proposals like this that i can write up if that's something people want 🤷

@eranhirsch
Copy link
Collaborator

These are all great and I don't mind adding them.

But be aware that their value in Python and other similar languages is that they rely heavily on the implementation using generators (yield) to make them efficient, as otherwise, they grow literally exponentially and could explode the memory in places where JS usually run which aren't optimized for memory-heavy computations like the browser and the edge.

Remeda has a notion of "iterator"-like API using our lazy evaluation mechanism, but it only works in pipes. This could trip users who use these methods naively in their dataFirst variant and we should avoid those situations:

for (const [a, b] of product(<BIG_ARRAY>, <BIG_ARRAY>)) {
  // The whole product array is first computed and loaded into memory
  // before an iterator over it is created by the engine...
  // Probably not what the user thought would happen
}

@eranhirsch
Copy link
Collaborator

@TkDodo - wdyt?

@eranhirsch eranhirsch added feature request New feature or request help wanted Extra attention is needed labels Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants