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
"Chunking" by an arbitrary condition #1
Comments
The operation you're thinking of is, confusingly enough, also named I might call it |
@towerofnix While only TC39 delegates can bring a proposal to committee, anyone from the community may author a proposal. If you feel strongly enough about a Anyway, since this isn't related to the chunking problem that this proposal is trying to solve, closing. |
Thanks a bunch for the answers, both. I'm not likely going to author one as I don't feel exceptionally strong about it and generally am busy and not too interested in the social aspects of making a proposal come together. I'll consider it of course (and the guidance from you helps), but just wanted to note that this idea is more than open for anyone else to prepare and share a proposal for it. |
Hey, this is mostly a meta question, because I understand that
chunks
andwindows
are purely based on counting. But a relatively common pattern in my code is to for example divide a list according to one of a number of conditions, comparing the current item with the previous:When I heard about the Array Grouping proposal, I thought it might be what I was looking for. But that behavior is different - it's about shuttling all the items from an array into particular buckets. It doesn't maintain the sequence. So what I'm looking for feels like somewhat "iterator-y" behavior, but I don't know if this kind of operation has any primitive in recent proposals, and I have no idea what it'd be called in other programming languages, either!
Here's a
reduce
-based implementation:And here's the implementation we actually use (which mutates/reuses the working array instead).
Sorry this isn't directly relevant to this proposal! It's just similar terminology to what i've pretty arbitrarily come up with; I figure there's at least a chance someone visiting this proposal might be looking for something similar.
By the way, I came to this proposal (eventually) from tc39/proposal-array-grouping#53 — I wanted to bring this up because the issue specifically brings up using an arbitrary condition (they just happen to use a count-value-by-two, which is vaguely similar to
chunks
). @jridgewell pointed out that there are two possible behaviors (since the issue was ambiguous) and while one is superfluous with the presence ofgroupBy
, the other is unique behavior "similar to python'sitertools.groupby
", which they said had been discussed in committee.Is there a different proposal I should head towards, or is that idea yet to be explored in a dedicated proposal, or generally taken off the table by committee discussion for other reasons?
The text was updated successfully, but these errors were encountered: