On Friday, 5 March 2021 at 02:43:36 UTC, H. S. Teoh wrote:
On Fri, Mar 05, 2021 at 02:13:39AM +0000, Jack via
Digitalmars-d-learn 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
[...]
Why not just .front? E.g.:
int[] data = [ 1,2,3,4,5 ];
auto r = data.filter!(v => v % 2 == 0);
assert(r.front == 2);
T
it loops over the entire array then returns, I'd like to stop as
soon as the predicate return true