Finding Max Value of Column in Multi-Dimesional Array

ag0aep6g anonymous at example.com
Fri Jul 5 19:56:54 UTC 2019


On 05.07.19 20:49, Samir wrote:
> As a follow-on to my earlier question, is there a way to pass a variable 
> to the `map` function that specifies the column, rather than hard-coding 
> it?  I'm thinking of something like:
> 
> p.map!("a[column]").maxElement.writeln;

You can't do that with the string style, because the string is turned 
into a function inside of `map`. Your `column` isn't visible there.

It works when you pass an actual callable instead, e.g. a lambda:

p.map!(a => a[column]).maxElement.writeln;


More information about the Digitalmars-d-learn mailing list