Is there any generic iteration function that stops at first match?
Jesse Phillips
Jesse.K.Phillips+D at gmail.com
Sat Mar 6 02:26:50 UTC 2021
On Friday, 5 March 2021 at 02:13:39 UTC, Jack wrote:
> something like filter[1] but that stops at first match? are
> there any native functions for this in D or I have to write
> one? just making sure to not reinvent the wheel
>
>
> [1]: https://devdocs.io/d/std_algorithm_iteration#filter
std.algorithm.searching.find
To summarize.
* filter.front
* find.front
* until
* find
The first two provide you data at the first match, `until`
produces a range exclusive of the first match.
If you just use find it will produce a range that starts at the
first match, unlike filter the range includes everything and not
just the matching data.
More information about the Digitalmars-d-learn
mailing list