generic indexOf() for arrays ?
Brad Anderson
eco at gnuk.net
Fri Apr 27 12:51:07 PDT 2012
On Friday, 27 April 2012 at 19:49:33 UTC, M.Gore wrote:
> I'd like to know if there's a generic function over arrays to
> find the index of a specific elemnt therein, something like,
> say:
>
> int indexOf(S) (in S[] arr, S elem);
>
> which works the same way the std.string.indexOf() function
> works... couldn't find anything in the std.array module for
> this scenario. Would be nice to have this functionality
> built-in somehow.
>
> Or is there a completely different / better approach to this in
> D?
> Thx, M.
countUntil in std.algorithm should work fine.
http://dlang.org/phobos/std_algorithm.html#countUntil
Regards,
Brad Anderson
More information about the Digitalmars-d
mailing list