Macaulay2 » Documentation
Packages » Macaulay2Doc :: tally
next | previous | forward | backward | up | index | toc

tally -- tally the elements of a list, sequence, array, or string

Synopsis

Description

It produces a hash table (multiset) y which tallies the frequencies of the occurrences of items in the list or string x, i.e., y_i is the number of times i appears in x, or is 0 if i doesn't appear in the list or string.

i1 : y = tally {1,2,3,a,b,1,2,a,1,2,{a,b},{a,b},a}

o1 = Tally{{a, b} => 2}
           1 => 3
           2 => 3
           3 => 1
           a => 3
           b => 1

o1 : Tally
i2 : y_2

o2 = 3
i3 : y_5

o3 = 0
i4 : y_{a,b}

o4 = 2
i5 : tally "Hello, world!"

o5 = Tally{  => 1}
           ! => 1
           , => 1
           d => 1
           e => 1
           H => 1
           l => 3
           o => 2
           r => 1
           w => 1

o5 : Tally

See also

Ways to use tally :

For the programmer

The object tally is a compiled function.