partition<T> static method
Splits list into a [matching, nonMatching] pair based on predicate.
final [evens, odds] = Arr.partition([1, 2, 3, 4], (n) => n.isEven);
// evens: [2, 4], odds: [1, 3]
Implementation
static List<List<T>> partition<T>(
Iterable<T> list,
bool Function(T) predicate,
) {
final yes = <T>[];
final no = <T>[];
for (final v in list) {
(predicate(v) ? yes : no).add(v);
}
return [yes, no];
}