pythonic-fp.iterables 5.1.1__tar.gz → 5.1.3__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 (21) hide show
  1. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/CHANGELOG.rst +63 -70
  2. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/PKG-INFO +11 -10
  3. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/README.rst +5 -3
  4. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/pyproject.toml +5 -6
  5. pythonic_fp_iterables-5.1.3/src/pythonic_fp/iterables/__init__.py +45 -0
  6. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/src/pythonic_fp/iterables/drop_take.py +31 -27
  7. pythonic_fp_iterables-5.1.3/src/pythonic_fp/iterables/drop_take.pyi +10 -0
  8. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/src/pythonic_fp/iterables/folding.py +10 -2
  9. pythonic_fp_iterables-5.1.3/src/pythonic_fp/iterables/folding.pyi +13 -0
  10. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/src/pythonic_fp/iterables/merging.py +25 -17
  11. pythonic_fp_iterables-5.1.3/src/pythonic_fp/iterables/merging.pyi +14 -0
  12. pythonic_fp_iterables-5.1.3/src/pythonic_fp/iterables/py.typed +0 -0
  13. pythonic_fp_iterables-5.1.1/src/pythonic_fp/iterables/__init__.py +0 -42
  14. pythonic_fp_iterables-5.1.1/src/pythonic_fp/iterables/drop_take.pyi +0 -33
  15. pythonic_fp_iterables-5.1.1/src/pythonic_fp/iterables/folding.pyi +0 -56
  16. pythonic_fp_iterables-5.1.1/src/pythonic_fp/iterables/merging.pyi +0 -38
  17. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/.gitignore +0 -0
  18. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/LICENSE +0 -0
  19. /pythonic_fp_iterables-5.1.1/src/pythonic_fp/iterables/py.typed → /pythonic_fp_iterables-5.1.3/src/pythonic_fp/iterables/__init__.pyi +0 -0
  20. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/tests/test_fold.py +0 -0
  21. {pythonic_fp_iterables-5.1.1 → pythonic_fp_iterables-5.1.3}/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 - 2025-08-02
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,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonic-fp-iterables
3
- Version: 5.1.1
4
- Summary: Library of functions for iterating iterables
3
+ Version: 5.1.3
4
+ Summary: Tools for iterables
5
5
  Keywords: iterables,iterators
6
6
  Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
7
7
  Requires-Python: >=3.13
@@ -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.1
18
- Requires-Dist: pythonic-fp-gadgets>=3.0.1
19
- Requires-Dist: pythonic-fp-sentinels>=2.1.0
17
+ Requires-Dist: pythonic-fp-fptools>=5.2.0
18
+ Requires-Dist: pythonic-fp-gadgets>=4.0.2
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,15 +42,17 @@ 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>`_
48
+ PyPI projects.
48
49
 
49
50
  Documentation
50
51
  -------------
51
52
 
52
53
  Documentation for this project is hosted on
53
54
  `GitHub Pages
54
- <https://grscheller.github.io/pythonic-fp/iterables/development/build/html>`_.
55
+ <https://grscheller.github.io/pythonic-fp/iterables>`_.
55
56
 
56
57
  Copyright and License
57
58
  ---------------------
@@ -17,15 +17,17 @@ 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>`_
23
+ PyPI projects.
22
24
 
23
25
  Documentation
24
26
  -------------
25
27
 
26
28
  Documentation for this project is hosted on
27
29
  `GitHub Pages
28
- <https://grscheller.github.io/pythonic-fp/iterables/development/build/html>`_.
30
+ <https://grscheller.github.io/pythonic-fp/iterables>`_.
29
31
 
30
32
  Copyright and License
31
33
  ---------------------
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pythonic-fp-iterables"
3
- version = "5.1.1"
3
+ version = "5.1.3"
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.1",
20
- "pythonic-fp-gadgets>=3.0.1",
21
- "pythonic-fp-sentinels>=2.1.0",
19
+ "pythonic-fp-fptools>=5.2.0",
20
+ "pythonic-fp-gadgets>=4.0.2",
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]
@@ -0,0 +1,45 @@
1
+ # Copyright 2023-2026 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
+ """
16
+ Tools for iterables
17
+ -------------------
18
+
19
+ .. admonition:: Library of functions for iterating iterables
20
+
21
+ +-----------+-------------------------------------------+
22
+ | Module | Description |
23
+ +===========+===========================================+
24
+ | merging | Concatenating and merging iterables |
25
+ +-----------+-------------------------------------------+
26
+ | drop_take | Dropping and taking values from iterables |
27
+ +-----------+-------------------------------------------+
28
+ | folding | Reducing and accumulating iterables |
29
+ +-----------+-------------------------------------------+
30
+
31
+ .. important::
32
+
33
+ **Assumptions:**
34
+
35
+ - iterables are not necessarily iterators
36
+ - at all times iterator protocol is assumed to be followed
37
+
38
+ - all iterators are assumed to be iterable
39
+ - for all iterators ``foobar`` we assume ``iter(foobar) is foobar``
40
+
41
+ """
42
+
43
+ __author__ = 'Geoffrey R. Scheller'
44
+ __copyright__ = 'Copyright (c) 2023-2026 Geoffrey R. Scheller'
45
+ __license__ = 'Apache License 2.0'
@@ -13,7 +13,13 @@
13
13
  # limitations under the License.
14
14
 
15
15
  """
16
- Module pythonic_fp.iterables.drop_take
16
+ Drop and Take
17
+ -------------
18
+
19
+ .. admonition:: module pythonic_fp.iterables.drop_take
20
+
21
+ Functions to drop or take values from an iterable.
22
+
17
23
  """
18
24
 
19
25
  from collections.abc import Callable, Iterable, Iterator
@@ -30,15 +36,12 @@ __all__ = [
30
36
  ]
31
37
 
32
38
 
33
- ## dropping and taking
34
-
35
-
36
39
  def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]:
37
40
  """Drop the next n values from iterable.
38
41
 
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
+ :param iterable: Iterable whose values are to be dropped.
43
+ :param n: Number of values to be dropped.
44
+ :returns: An iterator of the remaining values.
42
45
 
43
46
  """
44
47
  iterator = iter(iterable)
@@ -53,9 +56,9 @@ def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]:
53
56
  def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]:
54
57
  """Drop initial values from iterable while predicate is true.
55
58
 
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
59
+ :param iterable: Iterable whose values are to be dropped.
60
+ :param pred: Single argument Boolean valued function, the "predicate".
61
+ :returns: An iterator beginning where pred returned false.
59
62
 
60
63
  """
61
64
  iterator = iter(iterable)
@@ -73,9 +76,9 @@ def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[
73
76
  def take[D](iterable: Iterable[D], n: int) -> Iterator[D]:
74
77
  """Return an iterator of up to n initial values of an iterable.
75
78
 
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
79
+ :param Iterable: iterable providing the values to be taken.
80
+ :param n: Number of values to be dropped.
81
+ :returns: An iterator of up to n initial values from iterable.
79
82
 
80
83
  """
81
84
  iterator = iter(iterable)
@@ -91,11 +94,12 @@ def take_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[
91
94
  """Yield values from iterable while predicate is true.
92
95
 
93
96
  .. warning::
97
+
94
98
  Risk of value loss if iterable is multiple referenced iterator.
95
99
 
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
100
+ :param iterable: Iterable providing the values to be taken.
101
+ :param pred: Single argument Boolean valued function, the "predicate".
102
+ :returns: An Iterator of of values from iterable until predicate false.
99
103
 
100
104
  """
101
105
  iterator = iter(iterable)
@@ -115,12 +119,12 @@ def take_split[D](iterable: Iterable[D], n: int) -> tuple[Iterator[D], Iterator[
115
119
 
116
120
  .. Warning::
117
121
 
118
- **CONTRACT:** Do not access the second returned iterator until the
119
- first one is exhausted.
122
+ **CONTRACT:** Do not access the second returned iterator until the
123
+ first one is exhausted.
120
124
 
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
125
+ :param iterable: Iterable providing the values to be taken.
126
+ :param n: maximum Number of values to be taken.
127
+ :returns: An iterator of values taken and an iterator of remaining values.
124
128
 
125
129
  """
126
130
  iterator = iter(iterable)
@@ -136,12 +140,12 @@ def take_while_split[D](
136
140
 
137
141
  .. Warning::
138
142
 
139
- **CONTRACT:** Do not access the second returned iterator until
140
- the first one is exhausted.
143
+ **CONTRACT:** Do not access the second returned iterator until
144
+ the first one is exhausted.
141
145
 
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
146
+ :param iterable: Iterable providing the values to be taken.
147
+ :param pred: Single argument Boolean valued function.
148
+ :returns: Tuple of iterator of values taken and an iterator of remaining values.
145
149
 
146
150
  """
147
151
 
@@ -162,4 +166,4 @@ def take_while_split[D](
162
166
  value: Box[D] = Box()
163
167
  it_pred = _take_while(iterator, pred, value)
164
168
 
165
- return (it_pred, concat(value, iterator))
169
+ return it_pred, concat(value, iterator)
@@ -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]]: ...
@@ -12,13 +12,21 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- """Module pythonic_fp.iterables.folding"""
15
+ """
16
+ Folding
17
+ -------
18
+
19
+ .. admonition:: module pythonic_fp.iterables.folding
20
+
21
+ Functions to reduce and accumulate values from iterables.
22
+
23
+ """
16
24
 
17
25
  from collections.abc import Callable, Iterable, Iterator
18
26
  from typing import cast, Never
19
27
  from pythonic_fp.fptools.function import negate, swap
20
28
  from pythonic_fp.fptools.maybe import MayBe
21
- from pythonic_fp.sentinels.novalue import NoValue
29
+ from pythonic_fp.gadgets.sentinels.novalue import NoValue
22
30
  from .drop_take import drop_while, take_while_split
23
31
 
24
32
  __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]]: ...
@@ -12,7 +12,15 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- """Module pythonic_fp.iterables.merging"""
15
+ """
16
+ Merging Iterables
17
+ -----------------
18
+
19
+ .. admonition:: module pythonic_fp.iterables.merging
20
+
21
+ Functions to merge multiple iterables together into one.
22
+
23
+ """
16
24
 
17
25
  from collections.abc import Iterable, Iterator
18
26
  from enum import auto, Enum
@@ -51,8 +59,8 @@ def concat[D](*iterables: Iterable[D]) -> Iterator[D]:
51
59
 
52
60
  Performant to the standard library's ``itertools.chain``.
53
61
 
54
- :param iterables: iterables to concatenate
55
- :return: iterator of concatenated values from the iterables
62
+ :param iterables: Iterables to concatenate.
63
+ :returns: Iterator of concatenated values from the iterables.
56
64
 
57
65
  """
58
66
  for iterator in map(lambda x: iter(x), iterables):
@@ -69,13 +77,13 @@ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[
69
77
 
70
78
  .. note::
71
79
 
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.
80
+ When ``yield_partials`` is true, then any unmatched values from other iterables
81
+ already yielded when the first iterable is exhausted are yielded. This prevents
82
+ data lose if any of the iterables are iterators with external references.
75
83
 
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
84
+ :param iterables: Iterables to merge until one gets exhausted.
85
+ :param yield_partials: Yield any unpaired yielded values from other iterables.
86
+ :returns: Iterator of merged values from the iterables until one is exhausted.
79
87
 
80
88
  """
81
89
  iter_list = list(map(lambda x: iter(x), iterables))
@@ -96,8 +104,8 @@ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[
96
104
  def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]:
97
105
  """Merge together multiple iterables until all are exhausted.
98
106
 
99
- :param iterables: iterables to exhaustively merge
100
- :return: iterator of merged values from the iterables until all are exhausted
107
+ :param iterables: Iterables to exhaustively merge.
108
+ :returns: Iterator of merged values from the iterables until all are exhausted.
101
109
 
102
110
  """
103
111
  iter_list = list(map(lambda x: iter(x), iterables))
@@ -126,13 +134,13 @@ def blend[D](
126
134
  merge_enum: MergeEnum = MergeEnum.Concat,
127
135
  yield_partials: bool = False,
128
136
  ) -> Iterator[D]:
129
- """Base merge behavior on name only parameters.
137
+ """Merge behavior based on value of merge_enum parameter.
130
138
 
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
139
+ :param iterables: Iterables to blend together.
140
+ :param merge_enum: ``MergeEnum`` to determine merging behavior.
141
+ :param yield_partials: Yield unpaired values from other iterables.
142
+ :returns: An iterator of type ``D``.
143
+ :raises ValueError: When an unknown ``MergeEnum`` is given.
136
144
 
137
145
  """
138
146
  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,42 +0,0 @@
1
- # Copyright 2023-2024 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
- """
16
- Library of functions for iterating iterables
17
- ============================================
18
-
19
- +-----------+-------------------------------------------+
20
- | Module | Description |
21
- +===========+===========================================+
22
- | merging | Concatenating and merging iterables |
23
- +-----------+-------------------------------------------+
24
- | drop_take | Dropping and taking values from iterables |
25
- +-----------+-------------------------------------------+
26
- | folding | Reducing and accumulating iterables |
27
- +-----------+-------------------------------------------+
28
-
29
- Assumptions
30
- -----------
31
-
32
- - iterables are not necessarily iterators
33
- - at all times iterator protocol is assumed to be followed
34
-
35
- - all iterators are assumed to be iterable
36
- - for all iterators ``foobar`` we assume ``iter(foobar) is foobar``
37
-
38
- """
39
-
40
- __author__ = 'Geoffrey R. Scheller'
41
- __copyright__ = 'Copyright (c) 2023-2025 Geoffrey R. Scheller'
42
- __license__ = 'Apache License 2.0'
@@ -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]: ...