Message-ID: <20030605180423.19bc5b62.tobias_verbeke@skynet.be>
Date: 2003-06-05T16:04:23Z
From: Tobias Verbeke
Subject: dynamics of functions
Dear Thomas,
> What about the following function?
>
> iterate<-function(f,n,x){
> if(n==0) return(x)
> y<-x
> for(i in 1:n)y<-f(y)
> y
> }
> iterate(sqrt,3,256)
Thank you very much, this certainly helps.
I'm still curious, though, to know how to
write the expression of my function
immediately as the argument f.
I can define it outside of the function
> aap <- function(x) -x^3
and use it as argument
> iterate(aap,3,256),
but I seem not to be clever enough
to write a function that receives
the following as input
> iterate(-x^3,3,256)
Thanks again,
Tobias