most elegant functional way to make a histogram
Laeeth Isharc via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 24 11:32:54 PDT 2015
On Monday, 24 August 2015 at 09:50:41 UTC, yawniek wrote:
> On Friday, 21 August 2015 at 21:08:25 UTC, Laeeth Isharc wrote:
>> I guess this kind of thing will do:
>> upRangeHighs.each!((ref a)=>(++histogram[a][0]));
>
>
> int[] arr = [5,1,2,2,3,4,5,5,5];
> int[int] histo;
> arr.each!( a => ++histo[a] );
> writeln(histo);
>
> this works
Thanks v much for suggestions, everyone. In the end I just went
with something like the above.
More information about the Digitalmars-d-learn
mailing list