Is the FoldLeft function available in R?

Posted by JSmaga on Stack Overflow See other posts from Stack Overflow or by JSmaga
Published on 2010-06-15T04:00:04Z Indexed on 2010/06/15 4:02 UTC
Read the original article Hit count: 146

Filed under:
|
|

Hi,

I would like to know if there is an implementation of the foldLeft function (and foldRight?) in R.

The language is supposed to be "rather" functional oriented and hence I think there should be something like this, but I could not find it in the documentation.

To me, foldLeft function applies on a list and has the following signature:

foldLeft[B](z : B)(f : (B, A) => B) : B

It is supposed to return the following result:

f(... (f(f(z, a0), a1) ...), an) if the list is [a0, a1, ..., an].

(I use the definition of the Scala List API)

Does anybody know if such a function exists in R?

© Stack Overflow or respective owner

Related posts about r

    Related posts about functional-programming