Synopsis:
fold(f,{x0,x1,...,xn}) -- computes f(...f(f(x0,x1),x2)...)}.
i1 : fold(identity, {a,b,c,d,e}) |
i2 : fold(plus, {1,2,3,4,5}) |
Code:
-- ../../../Macaulay2/m2/fold.m2:16-18 fold(Function,VisibleList) := VisibleList => (f,v) -> ( if # v === 0 then error "expected a nonempty list"; fold(f,v#0,drop(v,1)))