How to search for an element in the array. D2 phobos.

Daniel Keep daniel.keep.lists at gmail.com
Sun Jul 12 23:26:52 PDT 2009



bearophile wrote:
> Eldar Insafutdinov:
>> I think I completely misunderstood how to use it.
> 
> Yes, it's too much complex. It tries to do many different things in the most efficient way possible, the result is a high complexity in usage. That's one of the faults of Andrei's code, it's not tested by letting  average coders use it.
> A solution for this problem is to offer simple functions (like you can find in Tango. In my dlibs the situation is intermediate, I think) with a simple API for the most common purposes.
> 
> Bye,
> bearophile

It should work.  Taken from the algorithm docs:

> Example:
>
> > int[] a = [ 1, 4, 2, 3 ];
> > assert(find(a, 4) == [ 4, 2, 3 ]);

That said, find is too complex for his purposes.  Amazingly, Phobos
still appears to lack a basic indexOf function.

Phobos2: can build a working sentient AI that can feel love up from
individual atoms, but can't find the index of an array element.  :P


More information about the Digitalmars-d-learn mailing list