Array Filtering for Stage 2
(and also grouping)
To Recap
filter keeps items which return true
This is the opposite behavior that some users expect.
Proposal is to add an “filter out” method
Would remove items which return true
Real Code!
Filtering out items
Use filterReject to reject the item
Array partitioning/grouping
Partitioning an array
Partitioning is special form of filtering
Issues with Partition
Grouping an Array
groupBy is a more generic form of partition
Grouping is extremely flexible
Needed to implement a stable sort in older node. We’re grouping nodes into integer keys, and sorting the keys. Concat, and voilà.
Also known as bucketing.
What return value?
Difference from python itertools.groupby
Python's itertools doesn't combine all groups, only sequential groups
Do we treat array holes as undefined?
Discussion
Stage 2?
(Both filterRejct and groupBy)