[GAP Forum] Frequencies in a list
Robert F. Morse
rm43 at evansville.edu
Wed Jan 5 00:23:38 GMT 2005
Bulutoglu Dursun A Civ AFIT/ENC wrote:
> Dear Gap Forum;
> I was wondering whether there is a function in GAP that does the
> following:
>
> Input: a list of numbers
> Output: the numbers in the list sorted from small to large and
> the frequencies at which they appear in the list.
> Dursun.
Dear Dursun,
Use the Collected command (see, Chapter 21.20 of the reference manual).
Example:
gap> Collected([1,1,1,1,1,1,2,2,-1,-1]);
[ [ -1, 2 ], [ 1, 6 ], [ 2, 2 ] ]
Regards, Robert F. Morse
More information about the Forum
mailing list