[R] fold right - recursive list (vector) operators
Mads Jeppe Tarp-Johansen
s02mjtj at math.ku.dk
Wed Nov 3 22:59:11 CET 2004
The programming language mosml comes with foldr that 'accumulates' a
function f over a list [x1,x2,...,xn] with initial value b as follows
foldr f b [x1,x2,...,xn] = f(x1,...,f(xn-1,f(xn,b))...)
Observe that "list" should have same elements so in R terminology it would
perhaps be appropriate to say that the accumulation takes place over a
'vector'.
I wonder if R comes with a similar function and in general a library or
package with list (vector) operators. Or is such programming style not
intended in R?
Regards MJ
More information about the R-help
mailing list