most elegant functional way to make a histogram

yawniek via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 24 02:50:39 PDT 2015


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




More information about the Digitalmars-d-learn mailing list