Re: NestList
- To: mathgroup at smc.vnet.net
- Subject: [mg50560] Re: NestList
- From: "Michael Taktikos" <michael.taktikos at hanse.net>
- Date: Fri, 10 Sep 2004 04:06:00 -0400 (EDT)
- References: <chpa26$jt6$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Yes, it is possible.
Example: You want to iterate the Cos-function 4 times to the starting value
x,
NestList[Cos, x, 4]
The iterator can be written as pure function #+1&, so you can use a list of
the two pure functions and apply it
to a list with two starting values, {0,x}:
In[1]:= NestList[{#[[1]]+1,Cos[#[[2]] ]}&,{0,x},4]
Out[1]=
{{0,x},{1,Cos[x]},{2,Cos[Cos[x]]},{3,Cos[Cos[Cos[x]]]},{4,Cos[Cos[Cos[Cos[x]
]]]}}
Greetings from Hamburg,
Michael Taktikos
"Namrata Khemka" <namrata.khemka at gmail.com> schrieb im Newsbeitrag
news:chpa26$jt6$1 at smc.vnet.net...
> Hello everyone,
>
> I have a question regarding NestList function.
>
> I am applying a function on the expression n times.
>
> NestList [function, expr, n]
>
> However in my function I would like to know what is the current value
> of n. In other words I would like to know what iteration it is on.
>
> Is this possible?
>
> Thanks in advance.
>
> Namrata Khemka
>