-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminate dependency on
nr-stream
(#266)
* Eliminate dependency on `nr-stream` * improve docstring * add .envrc * add changelog
- Loading branch information
1 parent
8d0edc4
commit ad00bd6
Showing
6 changed files
with
33 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
if which slap >/dev/null; then | ||
eval "$(slap venv -a)" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from collections.abc import Iterable | ||
from itertools import filterfalse, tee | ||
from typing import Callable, TypeVar | ||
|
||
T_co = TypeVar("T_co", covariant=True) | ||
|
||
|
||
def bipartition(predicate: Callable[[T_co], bool], it: Iterable[T_co]) -> tuple[Iterable[T_co], Iterable[T_co]]: | ||
""" | ||
Partition a stream into two separate streams based on a predicate. | ||
Returns: | ||
A tuple of two iterators, where the first iterator contains only the elements for which the *predicate* | ||
returned `False`, and the second iterator contains only the elements for which it returned `True`. | ||
""" | ||
|
||
t1, t2 = tee(it) | ||
return filterfalse(predicate, t1), filter(predicate, t2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters