[top][index]
search for:

sum Tally -- sum of elements

Synopsis:

  • Function: sum -- compute the sum
  • Input:
  • an instance of class Tally.
  • sum v -- yields the sum of the elements in the tally v.

    i1 : a = tally{1,1,1,1,1,10,10,10,100,100}

    o1 = Tally{1 => 5  }
               10 => 3
               100 => 2

    o1 : Tally
    i2 : sum a

    o2 = 235

    See also:

  • sum -- compute the sum
  • Code:

         -- ../../../Macaulay2/m2/set.m2:29
         sum(Tally) := (w) -> sum(pairs w, (k,v) -> v * k)

    [top][index]
    search for: