[top][index]
search for:

accumulate(Function,Thing,VisibleList) -- apply binary operator repeatedly

Synopsis:

  • Function: accumulate -- apply binary operator repeatedly
  • Input:
  • an instance of class Function.
  • an instance of class Thing.
  • an instance of class VisibleList.
  • Output:
  • an instance of class VisibleList.
  • accumulate(f,x0,{x1,...,xn}) -- computes the list {f(x0,x1),f(f(x0,x1),x2),...}.

    i1 : accumulate(identity, a, {b,c,d,e})

    o1 = {(a, b), ((a, b), c), (((a, b), c), d), ((((a, b), c), d), e)}

    o1 : List
    i2 : accumulate (times, 1, 1 .. 10)

    o2 = (1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800)

    o2 : Sequence

    Code:

         -- ../../../Macaulay2/m2/fold.m2:4
         accumulate(Function,Thing,VisibleList) := VisibleList => (f,x,v) -> apply(v, y -> x = f(x,y))

    [top][index]
    search for: