partition¶
-
sknano.core.itertools.
partition
(pred, iterable)[source] [edit on github][source]¶ Use a predicate to partition entries into false entries and true entries.
Parameters: Returns: Return type: tuple
ofIterables
Examples
>>> from sknano.core import partition >>> is_odd = lambda x: x % 2 != 0 >>> p = partition(is_odd, range(10)) >>> [print(i) for i in p] [[0, 2, 4, 6, 8], [1, 3, 5, 7, 9]]