Reduce help..

Timon Gehr timon.gehr at gmx.ch
Fri Sep 2 10:18:29 PDT 2011


On 09/02/2011 07:11 PM, Andrej Mitrovic wrote:
> string[2][] results;
> results ~= ["foo", ""];
> results ~= ["foobar", ""];
>
> size_t len;
> foreach (res; results)
> {
>      len = max(len, res[0].length);
> }
>
> That gives me '6'. I want to convert this to functional-style code
> with reduce. I've tried:
>
> len = reduce!(max!"a[0].length")(results);
>
> That's not it. Any clues?


len = reduce!max(map!"a[0].length"(results));


More information about the Digitalmars-d-learn mailing list