Re: Using filter with std.container.Array.

2017-03-22 Thread Soulsbane via Digitalmars-d-learn
On Thursday, 23 March 2017 at 03:02:54 UTC, Jonathan M Davis wrote: On Thursday, March 23, 2017 02:53:40 Soulsbane via Digitalmars-d-learn wrote: [...] find just iterates to the first element that matches. It doesn't affect the range beyond that. It works basically the same way that find

Re: Using filter with std.container.Array.

2017-03-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 23, 2017 02:53:40 Soulsbane via Digitalmars-d-learn wrote: > Thanks for the reply Jonathan! Yes, I was trying to find all the > ids that match but couldn't get find to work. So I think I have > missed something somewhere. > > As a quick example: > import std.stdio; > import

Re: Using filter with std.container.Array.

2017-03-22 Thread Soulsbane via Digitalmars-d-learn
On Wednesday, 22 March 2017 at 07:30:48 UTC, Jonathan M Davis wrote: On Wednesday, March 22, 2017 07:06:47 Soulsbane via Digitalmars-d-learn wrote: Example code: struct Foo { string name; size_t id; } Array!Foo foo_; I get errors when I try to use filter like this: auto found =

Re: Using filter with std.container.Array.

2017-03-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 22, 2017 07:06:47 Soulsbane via Digitalmars-d-learn wrote: > Example code: > struct Foo > { >string name; >size_t id; > } > > Array!Foo foo_; > > I get errors when I try to use filter like this: > > auto found = filter!((Foo data, size_t id) => data.id == > id)(foo_[],