Category
A tuple where the 1st element is an array of elements that passed the predicate (passed
) and the 2nd element are the elements that failed the predicate (failed
)
Iterable
Category
Split an iterable into 2 arrays of elements that passed or failed a provided predicate.
Time complexity: O(n)
Space complexity: O(n)
The iterable to partition
The predicate to apply to each element of iterable
. If the predicate returns a truthy value the element will be added to the passed
array in the result. Otherwise, it will be added to the failed
array.
A tuple where the 1st element is an array of elements that passed the predicate (passed
) and the 2nd element are the elements that failed the predicate (failed
)
Iterable
Split an iterable into 2 arrays of elements that passed or failed a provided type guard.
Time complexity: O(n)
Space complexity: O(n)