functional programming question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

functional programming question

Erich Neuwirth
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).


--
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: functional programming question

Gabor Grothendieck
See:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/54896.html

On 2/4/06, Erich Neuwirth <[hidden email]> wrote:

> 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).
>
>
> --
> Erich Neuwirth, University of Vienna
> Faculty of Computer Science
> Computer Supported Didactics Working Group
> Visit our SunSITE at http://sunsite.univie.ac.at
> Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

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