Skip to content
Prev 32967 / 398513 Next

dynamics of functions

Dear Tobias,
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)

Hope that helps.

Best wishes

Thomas


---

Thomas Hotz
Research Associate in Medical Statistics
University of Leicester
United Kingdom

Department of Epidemiology and Public Health
22-28 Princess Road West
Leicester
LE1 6TP
Tel +44 116 252-5410
Fax +44 116 252-5423

Division of Medicine for the Elderly
Department of Medicine
The Glenfield Hospital
Leicester
LE3 9QP
Tel +44 116 256-3643
Fax +44 116 232-2976