partition method
Splits the collection into two lists according to predicate.
The first list contains elements for which predicate yielded true,
while the second list contains elements for which predicate yielded
false.
Implementation
(List<E>, List<E>) partition(bool Function(E element) predicate) {
final a = <E>[];
final b = <E>[];
for (final item in this) {
if (predicate(item)) {
a.add(item);
} else {
b.add(item);
}
}
return (a, b);
}