Skip to content
Prev 85750 / 398503 Next

functional programming question

Many functional programming languages have a metafunction
which does the following:
it has two arguments, a function and a list of objects, all of the same
type.
The argument function itself has two arguments of the same type as all
the list objects, and the result of this function also is of the same type.
then
metafunction(f,list(x1,x2,....xn)) produces
f(x1,f(x2,f(x3,....,f(xn-1,xn)))..)
Does R have such a function, or do I need to code it myself?
In Scheme (Mathematica), this metafunction is called fold (Fold).