Fold in Mathematica (or reduce in Python) works as follows:

Fold[f, x, {a, b, c}] := f[f[f[x,a],b],c]

That is, f is a binary operator, x is the initial value, and the results are cascaded along the list. I've found it useful for reducing lists when I only have a function that accepts two arguments (e.g., merge in R).

Is there any R equivalent? I'm a newbie in R and having a hard time finding such one. Thank you.

Seung

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to