Hello ptrash, Sunday, June 7, 2009, 11:44:18 PM, you wrote:
> I have a list of pupils (type Pupil = (Name, Grade)) where I store the name > of the pupil and which grade he has. No I want to get the number (and > average number) of each grade. Something like 10 Pupils have a A (23%), 2 > Pupils have a B ( 4 %) etc it doesn't need variables, you just going to change your mind, Neo :) the way it may be calculated in FP is 1) sort list by grades 2) group it by grades 3) count number of elements in each group just look into Data.List functions. or, alternatively, read A Tour of the Haskell Prelude http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html http://undergraduate.csse.uwa.edu.au/units/CITS3211/lectureNotes/tourofprelude.html -- Best regards, Bulat mailto:[email protected] _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
