fold(VisibleList,Thing,Function) -- apply binary operator repeatedly
Synopsis:
fold({xn,...,x1},x0,f) -- computes f(...f(x2,f(x1,x0))...)}.
i1 : fold({a,b,c,d}, e, identity)
o1 = (a, (b, (c, (d, e))))
o1 : Sequence |
Code:
-- ../../../Macaulay2/m2/fold.m2:15
fold(VisibleList,Thing,Function) := VisibleList => (v,x,f) -> (scan(reverse v, w -> x = f(w,x)); x)