I wouldn't be disappointed to see array_partition() added to the language,
but the longer I think about it, a well-designed `array_group()` function
could provide the equivalent behavior as well as afford other than just 2
static groups.

It seems like the only relevant difference is the fact that
array_partition() always returns an indexed array of two arrays without
needing to push 2 empty arrays for padding. Theoretically, array_group()
might not return any subarrays when there are no qualifying items to
retain.  Does array_group() need an optional 3rd parameter which declares
an empty array for each nominated grouping key which can be nominated in a
particular order? Food for thought.

Instead of potentially creating array_partition() and eventually
array_group(), I feel any benefits of array_partition() should be baked
into an array_group() function for greater utility in a unified function.

mickmackusa

Reply via email to