Skip to content

Commit

Permalink
README: .skip: add until example
Browse files Browse the repository at this point in the history
  • Loading branch information
ebonnal committed Jan 17, 2025
1 parent 0837ec3 commit d1a9636
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ assert list(five_first_integers) == [0, 1, 2, 3, 4]

## `.skip`



> Skips the first specified number of elements:
```python
Expand All @@ -404,6 +402,14 @@ integers_after_five: Stream[int] = integers.skip(5)
assert list(integers_after_five) == [5, 6, 7, 8, 9]
```

> or skips elements `until` a predicate is satisfied:
```python
integers_after_five: Stream[int] = integers.skip(until=lambda n: n >= 5)

assert list(integers_after_five) == [5, 6, 7, 8, 9]
```


## `.distinct`

Expand Down
4 changes: 4 additions & 0 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ def test_skip_example(self) -> None:

assert list(integers_after_five) == [5, 6, 7, 8, 9]

integers_after_five = integers.skip(until=lambda n: n >= 5)

assert list(integers_after_five) == [5, 6, 7, 8, 9]

def test_distinct_example(self) -> None:
distinct_chars: Stream[str] = Stream("foobarfooo").distinct()

Expand Down

0 comments on commit d1a9636

Please sign in to comment.