Skip to content

Commit ed7ce40

Browse files
committed
adds count to docs
1 parent 56e33f0 commit ed7ce40

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ evaluation wherever possible.
2020
[dropwhile](#dropwhile)<br />
2121
[cycle](#cycle)<br />
2222
[repeat](#repeat)<br />
23+
[count](#count)<br />
2324
[groupby](#groupby)<br />
2425
[accumulate](#accumulate)<br />
2526
[compress](#compress)<br />
@@ -232,6 +233,28 @@ for (auto&& e : repeat(2)) {
232233
}
233234
```
234235

236+
count
237+
-----
238+
Effectively a `range` without a stopping point.<br />
239+
`count()` with no arguments will start counting from 0 with a positive
240+
step of 1.<br />
241+
`count(i)` will start counting from `i` with a positive step of 1.<br />
242+
`count(i, st)` will start counting from `i` with a step of `st`.
243+
244+
*Technical limitations*: Unlike Python which can use its long integer
245+
types when needed, count() will eventually exceed the
246+
maximum possible value for its type (or minimum with a negative step).
247+
When using a signed type it is up to the API user to ensure this does
248+
not happen. If the limit is exceeded for signed types, the result is
249+
undefined (as per the C++ standard).
250+
251+
The below will print `0 1 2` ... etc
252+
```c++
253+
for (auto&& i : count()) {
254+
cout << i << '\n';
255+
}
256+
```
257+
235258
groupby
236259
-------
237260
Separate an iterable into groups sharing a common key. The following example

0 commit comments

Comments
 (0)