pythonic-fp.iterables 5.1.0__tar.gz → 5.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/CHANGELOG.rst +63 -70
  2. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/PKG-INFO +9 -8
  3. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/README.rst +4 -2
  4. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/pyproject.toml +5 -6
  5. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/src/pythonic_fp/iterables/drop_take.py +23 -22
  6. pythonic_fp_iterables-5.1.2/src/pythonic_fp/iterables/drop_take.pyi +10 -0
  7. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/src/pythonic_fp/iterables/folding.py +1 -1
  8. pythonic_fp_iterables-5.1.2/src/pythonic_fp/iterables/folding.pyi +13 -0
  9. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/src/pythonic_fp/iterables/merging.py +15 -15
  10. pythonic_fp_iterables-5.1.2/src/pythonic_fp/iterables/merging.pyi +14 -0
  11. pythonic_fp_iterables-5.1.2/src/pythonic_fp/iterables/py.typed +0 -0
  12. pythonic_fp_iterables-5.1.0/src/pythonic_fp/iterables/drop_take.pyi +0 -33
  13. pythonic_fp_iterables-5.1.0/src/pythonic_fp/iterables/folding.pyi +0 -56
  14. pythonic_fp_iterables-5.1.0/src/pythonic_fp/iterables/merging.pyi +0 -38
  15. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/.gitignore +0 -0
  16. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/LICENSE +0 -0
  17. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/src/pythonic_fp/iterables/__init__.py +0 -0
  18. /pythonic_fp_iterables-5.1.0/src/pythonic_fp/iterables/py.typed → /pythonic_fp_iterables-5.1.2/src/pythonic_fp/iterables/__init__.pyi +0 -0
  19. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/tests/test_fold.py +0 -0
  20. {pythonic_fp_iterables-5.1.0 → pythonic_fp_iterables-5.1.2}/tests/test_iterable.py +0 -0
@@ -17,20 +17,25 @@ See `Semantic Versioning 2.0.0 <https://semver.org>`_.
17
17
  Releases and Important Milestones
18
18
  ---------------------------------
19
19
 
20
- 5.1.0 - TBD
21
- ~~~~~~~~~~~
20
+ PyPI 5.1.1 - 2025-08-02
21
+ ~~~~~~~~~~~~~~~~~~~~~~~
22
+
23
+ Only docstring changes.
24
+
25
+ PyPI 5.1.0 - 2025-08-02
26
+ ~~~~~~~~~~~~~~~~~~~~~~~
22
27
 
23
28
  - changed singletons -> sentinels
24
29
  - Removed "from __future__ import annotations"
25
30
  - Added .pyi files
26
31
 
27
- 5.0.0 - 2025-08-02
28
- ~~~~~~~~~~~~~~~~~~
32
+ PyPI 5.0.0 - 2025-08-02
33
+ ~~~~~~~~~~~~~~~~~~~~~~~
29
34
 
30
35
  General consistency tweaks and fixes across all pythonic-fp projects.
31
36
 
32
- 4.0.0 - 2025-07-16
33
- ~~~~~~~~~~~~~~~~~~
37
+ PyPI 4.0.0 - 2025-07-16
38
+ ~~~~~~~~~~~~~~~~~~~~~~~
34
39
 
35
40
  Primary purpose was to bring Sphinx documentation in alignment
36
41
  with other pythonic-fp projects. Ended up making substantial
@@ -41,15 +46,15 @@ for the other pythonic-fp projects.
41
46
 
42
47
  - renamed pythonic_fp.iterables.foldl to pythonic_fp.iterables.fold_left
43
48
 
44
- 3.0.0 - 2025-07-06
45
- ~~~~~~~~~~~~~~~~~~
49
+ PyPI 3.0.0 - 2025-07-06
50
+ ~~~~~~~~~~~~~~~~~~~~~~~
46
51
 
47
52
  First PyPI release as ``pythonic-fp.iterables``
48
53
 
49
54
  - dropping dtools namespace name because there is a repo by that name.
50
55
 
51
- 2.0.0 - 2025-05-22
52
- ~~~~~~~~~~~~~~~~~~
56
+ PyPI 2.0.0 - 2025-05-22
57
+ ~~~~~~~~~~~~~~~~~~~~~~~
53
58
 
54
59
  - Moved dtools.fp.iterables to its own PyPI project
55
60
 
@@ -63,8 +68,8 @@ First PyPI release as ``pythonic-fp.iterables``
63
68
 
64
69
  - will import dtools.fp.lazy directly for this functionality
65
70
 
66
- 1.7.0 - 2025-04-22
67
- ~~~~~~~~~~~~~~~~~~
71
+ PyPI 1.7.0 - 2025-04-22
72
+ ~~~~~~~~~~~~~~~~~~~~~~~
68
73
 
69
74
  Last PyPI release as dtools.fp
70
75
 
@@ -73,21 +78,21 @@ Last PyPI release as dtools.fp
73
78
  - docstring changes
74
79
  - pyproject.toml standardization
75
80
 
76
- 1.6.0 - 2025-04-07
77
- ~~~~~~~~~~~~~~~~~~
81
+ PyPI 1.6.0 - 2025-04-07
82
+ ~~~~~~~~~~~~~~~~~~~~~~~
78
83
 
79
84
  - typing improvements
80
85
 
81
- 1.4.0 - 2025-03-16
82
- ~~~~~~~~~~~~~~~~~~
86
+ PyPI 1.4.0 - 2025-03-16
87
+ ~~~~~~~~~~~~~~~~~~~~~~~
83
88
 
84
89
  - much work dtools.iterables
85
90
 
86
91
  - finally implemented scReduceL and scReduceR functions
87
92
  - tweaked API across iterables module
88
93
 
89
- 1.3.0 - 2025-01-17
90
- ~~~~~~~~~~~~~~~~~~
94
+ PyPI 1.3.0 - 2025-01-17
95
+ ~~~~~~~~~~~~~~~~~~~~~~~
91
96
 
92
97
  First release as dtools.fp
93
98
 
@@ -96,85 +101,73 @@ Repo name changes.
96
101
  - GitHub: fp -> dtools-fp
97
102
  - PyPI: grscheller.fp -> dtools.fp
98
103
 
99
- 1.0.1 - 2024-10-20
100
- ~~~~~~~~~~~~~~~~~~
104
+ PyPI 1.0.1 - 2024-10-20
105
+ ~~~~~~~~~~~~~~~~~~~~~~~
101
106
 
102
107
  - removed docs from repo
103
108
  - docs for all grscheller namespace projects maintained here
104
109
 
105
110
  - https://grscheller.github.io/grscheller-pypi-namespace-docs/
106
111
 
107
- 1.0.0 - 2024-10-18
108
- ~~~~~~~~~~~~~~~~~~
112
+ PyPI 1.0.0 - 2024-10-18
113
+ ~~~~~~~~~~~~~~~~~~~~~~~
109
114
 
110
115
  Decided to make this release first stable release.
111
116
 
112
117
  - renamed module fp.woException to fp.err_handling
113
118
  - pytest improvements based on pytest documentation
114
119
 
115
- 0.4.0 - 2024-10-03
116
- ~~~~~~~~~~~~~~~~~~
120
+ PyPI 0.4.0 - 2024-10-03
121
+ ~~~~~~~~~~~~~~~~~~~~~~~
117
122
 
118
123
  Long overdue PyPI release.
119
124
 
120
- 0.3.4.0 - 2024-09-30
121
- ~~~~~~~~~~~~~~~~~~~~
122
-
123
- Development environment only.
124
-
125
- - API change for fp.iterables
126
-
127
- - function name changes
128
-
129
- - ``foldL``, ``foldR``, ``foldLsc``, ``foldRsc``
130
- - ``sc`` stands for "short circuit"
131
-
132
- - all now return class woException.MB
133
-
134
- 0.3.3.7 - 2024-09-22
135
- ~~~~~~~~~~~~~~~~~~~~
125
+ Version 0.3.4.0 - 2024-09-30 (Devel environment only)
126
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
136
127
 
137
- Development environment only.
128
+ API change for fp.iterables.
138
129
 
139
- - added more functions to fp.iterables module
130
+ - function name changes
140
131
 
141
- - take(it: Iterable[D], n: int) -> Iterator[D]
142
- - takeWhile(it: Iterable[D], pred: Callable\[[D], bool\]) -> Iterator[D]
143
- - drop(it: Iterable[D], n: int) -> Iterator[D]
144
- - dropWhile(it: Iterable[D], pred: Callable\[[D], bool\]) -> Iterator[D]
132
+ - ``foldL``, ``foldR``, ``foldLsc``, ``foldRsc``
133
+ - ``sc`` stands for "short circuit"
145
134
 
146
- 0.3.3.4 - 2024-09-16
147
- ~~~~~~~~~~~~~~~~~~~~
135
+ - all now return class woException.MB
148
136
 
149
- Development environment only.
137
+ Version 0.3.3.7 - 2024-09-22 (Devel environment only)
138
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150
139
 
151
- - fp.iterables ``foldL_sc`` & ``foldR_sc`` now have
140
+ Added more functions to fp.iterables module.
152
141
 
153
- - common paradigm
154
- - similar signatures
142
+ - take(it: Iterable[D], n: int) -> Iterator[D]
143
+ - takeWhile(it: Iterable[D], pred: Callable\[[D], bool\]) -> Iterator[D]
144
+ - drop(it: Iterable[D], n: int) -> Iterator[D]
145
+ - dropWhile(it: Iterable[D], pred: Callable\[[D], bool\]) -> Iterator[D]
155
146
 
156
- 0.3.3.3 - 2024-09-15
157
- ~~~~~~~~~~~~~~~~~~~~
147
+ Version 0.3.3.4 - 2024-09-16 (Devel environment only)
148
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158
149
 
159
- Development environment only.
150
+ Both ``foldL_sc`` and ``foldR_sc`` now have a common paradigm
151
+ and similar signatures.
160
152
 
161
- - added fp.iterables function ``foldR_sc``
153
+ Version 0.3.3.3 - 2024-09-15 (Devel environment only)
154
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
162
155
 
163
- - shortcut version of ``foldR``
164
- - not fully tested
165
- - docstring not updated
156
+ Added fp.iterables function ``foldR_sc``
166
157
 
167
- 0.3.3.2 - 2024-09-14
168
- ~~~~~~~~~~~~~~~~~~~~
158
+ - shortcut version of ``foldR``
159
+ - not fully tested
160
+ - docstring not updated
169
161
 
170
- Development environment only.
162
+ Version 0.3.3.2 - 2024-09-14 (Devel environment only)
163
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171
164
 
172
- - added fp.iterables function ``foldL_sc``
165
+ Added ``foldL_sc``, shortcut version of foldL,
166
+ to fp.iterables.
173
167
 
174
- - shortcut version of foldL
175
168
 
176
- 0.3.1 - 2024-08-20
177
- ~~~~~~~~~~~~~~~~~~
169
+ PyPI 0.3.1 - 2024-08-20
170
+ ~~~~~~~~~~~~~~~~~~~~~~~
178
171
 
179
172
  Now fp.iterables no longer exports ``CONCAT``, ``MERGE``, ``EXHAUST``.
180
173
 
@@ -183,8 +176,8 @@ Now fp.iterables no longer exports ``CONCAT``, ``MERGE``, ``EXHAUST``.
183
176
  - grscheller.datastructures.ftuple
184
177
  - grscheller.datastructures.split_ends
185
178
 
186
- 0.2.0 - 2024-07-26
187
- ~~~~~~~~~~~~~~~~~~
179
+ PyPI 0.2.0 - 2024-07-26
180
+ ~~~~~~~~~~~~~~~~~~~~~~~
188
181
 
189
182
  - from last PyPI release
190
183
 
@@ -192,8 +185,8 @@ Now fp.iterables no longer exports ``CONCAT``, ``MERGE``, ``EXHAUST``.
192
185
 
193
186
  - overall much better docstrings
194
187
 
195
- 0.1.0 - 2024-07-11
196
- ~~~~~~~~~~~~~~~~~~
188
+ PyPI 0.1.0 - 2024-07-11
189
+ ~~~~~~~~~~~~~~~~~~~~~~~
197
190
 
198
191
  Initial PyPI release as grscheller.fp
199
192
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonic-fp-iterables
3
- Version: 5.1.0
3
+ Version: 5.1.2
4
4
  Summary: Library of functions for iterating iterables
5
5
  Keywords: iterables,iterators
6
6
  Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
@@ -14,13 +14,12 @@ Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Typing :: Typed
16
16
  License-File: LICENSE
17
- Requires-Dist: pythonic-fp-fptools>=5.1.0
18
- Requires-Dist: pythonic-fp-gadgets>=3.0.1
19
- Requires-Dist: pythonic-fp-sentinels>=2.1.1
17
+ Requires-Dist: pythonic-fp-fptools>=5.1.2
18
+ Requires-Dist: pythonic-fp-gadgets>=3.1.0
20
19
  Requires-Dist: pytest>=8.4.1 ; extra == "test"
21
20
  Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-iterables/blob/main/CHANGELOG.rst
22
- Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/iterables/development/build/html/releases.html
23
- Project-URL: Homepage, https://github.com/grscheller/pythonic-fp/blob/main/README.md
21
+ Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/iterables/development/build/html/
22
+ Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/homepage/build/html/
24
23
  Project-URL: Source, https://github.com/grscheller/pythonic-fp-iterables
25
24
  Provides-Extra: test
26
25
 
@@ -43,8 +42,10 @@ Library of functions for iterating iterables.
43
42
  - all iterators are assumed to be iterable
44
43
  - for all iterators ``foo`` we assume ``iter(foo) is foo``
45
44
 
46
- This PyPI project is part of of the
47
- `pythonic-fp namespace projects <https://github.com/grscheller/pythonic-fp/blob/main/README.md>`_
45
+ Part of the
46
+ `pythonic-fp
47
+ <https://grscheller.github.io/pythonic-fp/homepage/build/html/index.html>`_
48
+ PyPI projects.
48
49
 
49
50
  Documentation
50
51
  -------------
@@ -17,8 +17,10 @@ Library of functions for iterating iterables.
17
17
  - all iterators are assumed to be iterable
18
18
  - for all iterators ``foo`` we assume ``iter(foo) is foo``
19
19
 
20
- This PyPI project is part of of the
21
- `pythonic-fp namespace projects <https://github.com/grscheller/pythonic-fp/blob/main/README.md>`_
20
+ Part of the
21
+ `pythonic-fp
22
+ <https://grscheller.github.io/pythonic-fp/homepage/build/html/index.html>`_
23
+ PyPI projects.
22
24
 
23
25
  Documentation
24
26
  -------------
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pythonic-fp-iterables"
3
- version = "5.1.0"
3
+ version = "5.1.2"
4
4
  readme = "README.rst"
5
5
  requires-python = ">=3.13"
6
6
  license = { file = "LICENSE" }
@@ -16,16 +16,15 @@ classifiers = [
16
16
  "Typing :: Typed",
17
17
  ]
18
18
  dependencies = [
19
- "pythonic-fp-fptools>=5.1.0",
20
- "pythonic-fp-gadgets>=3.0.1",
21
- "pythonic-fp-sentinels>=2.1.1",
19
+ "pythonic-fp-fptools>=5.1.2",
20
+ "pythonic-fp-gadgets>=3.1.0",
22
21
  ]
23
22
  dynamic = ["description"]
24
23
 
25
24
  [project.urls]
26
25
  Changelog = "https://github.com/grscheller/pythonic-fp-iterables/blob/main/CHANGELOG.rst"
27
- Documentation = "https://grscheller.github.io/pythonic-fp/iterables/development/build/html/releases.html"
28
- Homepage = "https://github.com/grscheller/pythonic-fp/blob/main/README.md"
26
+ Documentation = "https://grscheller.github.io/pythonic-fp/iterables/development/build/html/"
27
+ Homepage = "https://grscheller.github.io/pythonic-fp/homepage/build/html/"
29
28
  Source = "https://github.com/grscheller/pythonic-fp-iterables"
30
29
 
31
30
  [project.optional-dependencies]
@@ -36,9 +36,9 @@ __all__ = [
36
36
  def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]:
37
37
  """Drop the next n values from iterable.
38
38
 
39
- :param iterable: iterable whose values are to be dropped
40
- :param n: number of values to be dropped
41
- :returns: an iterator of the remaining values
39
+ :param iterable: Iterable whose values are to be dropped.
40
+ :param n: Number of values to be dropped.
41
+ :returns: An iterator of the remaining values.
42
42
 
43
43
  """
44
44
  iterator = iter(iterable)
@@ -53,9 +53,9 @@ def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]:
53
53
  def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]:
54
54
  """Drop initial values from iterable while predicate is true.
55
55
 
56
- :param iterable: iterable whose values are to be dropped
57
- :param pred: Boolean valued function, the "predicate"
58
- :return: an iterator beginning where pred returned false
56
+ :param iterable: Iterable whose values are to be dropped.
57
+ :param pred: Single argument Boolean valued function, the "predicate".
58
+ :returns: An iterator beginning where pred returned false.
59
59
 
60
60
  """
61
61
  iterator = iter(iterable)
@@ -73,9 +73,9 @@ def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[
73
73
  def take[D](iterable: Iterable[D], n: int) -> Iterator[D]:
74
74
  """Return an iterator of up to n initial values of an iterable.
75
75
 
76
- :param iterable: iterable providing the values to be taken
77
- :param n: number of values to be dropped
78
- :return: an iterator of up to n initial values from iterable
76
+ :param Iterable: iterable providing the values to be taken.
77
+ :param n: Number of values to be dropped.
78
+ :returns: An iterator of up to n initial values from iterable.
79
79
 
80
80
  """
81
81
  iterator = iter(iterable)
@@ -91,11 +91,12 @@ def take_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[
91
91
  """Yield values from iterable while predicate is true.
92
92
 
93
93
  .. warning::
94
+
94
95
  Risk of value loss if iterable is multiple referenced iterator.
95
96
 
96
- :param iterable: iterable providing the values to be taken
97
- :param pred: Boolean valued function, the "predicate"
98
- :return: an Iterator of of values from iterable until predicate false
97
+ :param iterable: Iterable providing the values to be taken.
98
+ :param pred: Single argument Boolean valued function, the "predicate".
99
+ :returns: An Iterator of of values from iterable until predicate false.
99
100
 
100
101
  """
101
102
  iterator = iter(iterable)
@@ -115,12 +116,12 @@ def take_split[D](iterable: Iterable[D], n: int) -> tuple[Iterator[D], Iterator[
115
116
 
116
117
  .. Warning::
117
118
 
118
- **CONTRACT:** Do not access the second returned iterator until the
119
- first one is exhausted.
119
+ **CONTRACT:** Do not access the second returned iterator until the
120
+ first one is exhausted.
120
121
 
121
- :param iterable: iterable providing the values to be taken
122
- :param n: maximum number of values to be taken
123
- :return: an iterator of values taken and an iterator of remaining values
122
+ :param iterable: Iterable providing the values to be taken.
123
+ :param n: maximum Number of values to be taken.
124
+ :returns: An iterator of values taken and an iterator of remaining values.
124
125
 
125
126
  """
126
127
  iterator = iter(iterable)
@@ -136,12 +137,12 @@ def take_while_split[D](
136
137
 
137
138
  .. Warning::
138
139
 
139
- **CONTRACT:** Do not access the second returned iterator until
140
- the first one is exhausted.
140
+ **CONTRACT:** Do not access the second returned iterator until
141
+ the first one is exhausted.
141
142
 
142
- :param iterable: iterable providing the values to be taken
143
- :param pred: Boolean valued function
144
- :return: tuple containing an iterator of values taken and an iterator of remaining values
143
+ :param iterable: Iterable providing the values to be taken.
144
+ :param pred: Single argument Boolean valued function.
145
+ :returns: Tuple of iterator of values taken and an iterator of remaining values.
145
146
 
146
147
  """
147
148
 
@@ -0,0 +1,10 @@
1
+ from collections.abc import Callable, Iterable, Iterator
2
+
3
+ __all__ = ['drop', 'drop_while', 'take', 'take_while', 'take_split', 'take_while_split']
4
+
5
+ def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]: ...
6
+ def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]: ...
7
+ def take[D](iterable: Iterable[D], n: int) -> Iterator[D]: ...
8
+ def take_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]: ...
9
+ def take_split[D](iterable: Iterable[D], n: int) -> tuple[Iterator[D], Iterator[D]]: ...
10
+ def take_while_split[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> tuple[Iterator[D], Iterator[D]]: ...
@@ -18,7 +18,7 @@ from collections.abc import Callable, Iterable, Iterator
18
18
  from typing import cast, Never
19
19
  from pythonic_fp.fptools.function import negate, swap
20
20
  from pythonic_fp.fptools.maybe import MayBe
21
- from pythonic_fp.sentinels.novalue import NoValue
21
+ from pythonic_fp.gadgets.sentinels.novalue import NoValue
22
22
  from .drop_take import drop_while, take_while_split
23
23
 
24
24
  __all__ = [
@@ -0,0 +1,13 @@
1
+ from collections.abc import Callable, Iterable, Iterator
2
+ from pythonic_fp.fptools.maybe import MayBe
3
+ from pythonic_fp.gadgets.sentinels.novalue import NoValue
4
+ from typing import Never
5
+
6
+ __all__ = ['accumulate', 'reduce_left', 'fold_left', 'maybe_fold_left', 'sc_reduce_left', 'sc_reduce_right']
7
+
8
+ def accumulate[D, L](iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = ...) -> Iterator[L]: ...
9
+ def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D | Never: ...
10
+ def fold_left[D, L](iterable: Iterable[D], f: Callable[[L, D], L], initial: L) -> L | Never: ...
11
+ def maybe_fold_left[D, L](iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = ...) -> MayBe[L] | Never: ...
12
+ def sc_reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D], start: Callable[[D], bool] = ..., stop: Callable[[D], bool] = ..., include_start: bool = True, include_stop: bool = True) -> tuple[MayBe[D], Iterator[D]]: ...
13
+ def sc_reduce_right[D](iterable: Iterable[D], f: Callable[[D, D], D], start: Callable[[D], bool] = ..., stop: Callable[[D], bool] = ..., include_start: bool = True, include_stop: bool = True) -> tuple[MayBe[D], Iterator[D]]: ...
@@ -51,8 +51,8 @@ def concat[D](*iterables: Iterable[D]) -> Iterator[D]:
51
51
 
52
52
  Performant to the standard library's ``itertools.chain``.
53
53
 
54
- :param iterables: iterables to concatenate
55
- :return: iterator of concatenated values from the iterables
54
+ :param iterables: Iterables to concatenate.
55
+ :returns: Iterator of concatenated values from the iterables.
56
56
 
57
57
  """
58
58
  for iterator in map(lambda x: iter(x), iterables):
@@ -69,13 +69,13 @@ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[
69
69
 
70
70
  .. note::
71
71
 
72
- When ``yield_partials`` is true, then any unmatched values from other iterables
73
- already yielded when the first iterable is exhausted are yielded. This prevents
74
- data lose if any of the iterables are iterators with external references.
72
+ When ``yield_partials`` is true, then any unmatched values from other iterables
73
+ already yielded when the first iterable is exhausted are yielded. This prevents
74
+ data lose if any of the iterables are iterators with external references.
75
75
 
76
- :param iterables: iterables to merge until one gets exhausted
77
- :param yield_partials: yield any unpaired yielded values from other iterables
78
- :return: iterator of merged values from the iterables until one is exhausted
76
+ :param iterables: Iterables to merge until one gets exhausted.
77
+ :param yield_partials: Yield any unpaired yielded values from other iterables.
78
+ :returns: Iterator of merged values from the iterables until one is exhausted.
79
79
 
80
80
  """
81
81
  iter_list = list(map(lambda x: iter(x), iterables))
@@ -96,8 +96,8 @@ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[
96
96
  def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]:
97
97
  """Merge together multiple iterables until all are exhausted.
98
98
 
99
- :param iterables: iterables to exhaustively merge
100
- :return: iterator of merged values from the iterables until all are exhausted
99
+ :param iterables: Iterables to exhaustively merge.
100
+ :returns: Iterator of merged values from the iterables until all are exhausted.
101
101
 
102
102
  """
103
103
  iter_list = list(map(lambda x: iter(x), iterables))
@@ -128,11 +128,11 @@ def blend[D](
128
128
  ) -> Iterator[D]:
129
129
  """Base merge behavior on name only parameters.
130
130
 
131
- :param iterables: iterables to blend together
132
- :param merge_enum: MergeEnum to determine merging behavior
133
- :param yield_partials: yield yielded unpaired values from other iterables
134
- :return: an iterator of type D
135
- :raises ValueError: when an unknown MergeEnum is given
131
+ :param iterables: Iterables to blend together.
132
+ :param merge_enum: ``MergeEnum`` to determine merging behavior.
133
+ :param yield_partials: Yield unpaired values from other iterables.
134
+ :returns: An iterator of type ``D``.
135
+ :raises ValueError: When an unknown ``MergeEnum`` is given.
136
136
 
137
137
  """
138
138
  match merge_enum:
@@ -0,0 +1,14 @@
1
+ from collections.abc import Iterable, Iterator
2
+ from enum import Enum
3
+
4
+ __all__ = ['MergeEnum', 'concat', 'merge', 'exhaust', 'blend']
5
+
6
+ class MergeEnum(Enum):
7
+ Concat = ...
8
+ Merge = ...
9
+ Exhaust = ...
10
+
11
+ def concat[D](*iterables: Iterable[D]) -> Iterator[D]: ...
12
+ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[D]: ...
13
+ def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]: ...
14
+ def blend[D](*iterables: Iterable[D], merge_enum: MergeEnum = ..., yield_partials: bool = False) -> Iterator[D]: ...
@@ -1,33 +0,0 @@
1
- # Copyright 2023-2025 Geoffrey R. Scheller
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- from collections.abc import Callable, Iterable, Iterator
16
-
17
- __all__ = [
18
- 'drop',
19
- 'drop_while',
20
- 'take',
21
- 'take_while',
22
- 'take_split',
23
- 'take_while_split',
24
- ]
25
-
26
- def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]: ...
27
- def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]: ...
28
- def take[D](iterable: Iterable[D], n: int) -> Iterator[D]: ...
29
- def take_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]: ...
30
- def take_split[D](iterable: Iterable[D], n: int) -> tuple[Iterator[D], Iterator[D]]: ...
31
- def take_while_split[D](
32
- iterable: Iterable[D], pred: Callable[[D], bool]
33
- ) -> tuple[Iterator[D], Iterator[D]]: ...
@@ -1,56 +0,0 @@
1
- # Copyright 2023-2025 Geoffrey R. Scheller
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- from collections.abc import Callable, Iterable, Iterator
16
- from typing import cast, Never
17
- from pythonic_fp.fptools.function import negate, swap
18
- from pythonic_fp.fptools.maybe import MayBe
19
- from pythonic_fp.sentinels.novalue import NoValue
20
- from .drop_take import drop_while, take_while_split
21
-
22
- __all__ = [
23
- 'accumulate',
24
- 'reduce_left',
25
- 'fold_left',
26
- 'maybe_fold_left',
27
- 'sc_reduce_left',
28
- 'sc_reduce_right',
29
- ]
30
-
31
- def accumulate[D, L](
32
- iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = NoValue()
33
- ) -> Iterator[L]: ...
34
- def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D | Never: ...
35
- def fold_left[D, L](
36
- iterable: Iterable[D], f: Callable[[L, D], L], initial: L
37
- ) -> L | Never: ...
38
- def maybe_fold_left[D, L](
39
- iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = NoValue()
40
- ) -> MayBe[L] | Never: ...
41
- def sc_reduce_left[D](
42
- iterable: Iterable[D],
43
- f: Callable[[D, D], D],
44
- start: Callable[[D], bool] = (lambda d: True),
45
- stop: Callable[[D], bool] = (lambda d: False),
46
- include_start: bool = True,
47
- include_stop: bool = True,
48
- ) -> tuple[MayBe[D], Iterator[D]]: ...
49
- def sc_reduce_right[D](
50
- iterable: Iterable[D],
51
- f: Callable[[D, D], D],
52
- start: Callable[[D], bool] = (lambda d: False),
53
- stop: Callable[[D], bool] = (lambda d: False),
54
- include_start: bool = True,
55
- include_stop: bool = True,
56
- ) -> tuple[MayBe[D], Iterator[D]]: ...
@@ -1,38 +0,0 @@
1
- # Copyright 2023-2025 Geoffrey R. Scheller
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- from collections.abc import Iterable, Iterator
16
- from enum import auto, Enum
17
-
18
- __all__ = [
19
- 'MergeEnum',
20
- 'concat',
21
- 'merge',
22
- 'exhaust',
23
- 'blend',
24
- ]
25
-
26
- class MergeEnum(Enum):
27
- Concat = auto()
28
- Merge = auto()
29
- Exhaust = auto()
30
-
31
- def concat[D](*iterables: Iterable[D]) -> Iterator[D]: ...
32
- def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[D]: ...
33
- def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]: ...
34
- def blend[D](
35
- *iterables: Iterable[D],
36
- merge_enum: MergeEnum = MergeEnum.Concat,
37
- yield_partials: bool = False,
38
- ) -> Iterator[D]: ...