Re: Re: NestList
- To: mathgroup at smc.vnet.net
- Subject: [mg50558] Re: Re: [mg50541] NestList
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 10 Sep 2004 04:05:58 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
This includes a timing: Clear[myNest, myNestList]; myNest[f_, expr_, n_Integer] := Last[myNestList[f, expr, n]]; myNestList[f_, expr_, n_Integer] := Module[{m = 1, g, t0 = AbsoluteTime[]}, g[x_] := Module[{}, Print["Starting iteration #" <> ToString[m++] <> " at time " <> ToString[AbsoluteTime[] - t0]]; f[x]]; NestList[g, expr, n]]; Bob Hanlon > > From: Bob Hanlon <hanlonr at cox.net> To: mathgroup at smc.vnet.net > Date: 2004/09/09 Thu AM 07:13:51 EDT > To: Namrata Khemka <namrata.khemka at gmail.com>, <mathgroup at smc.vnet.net> > Subject: [mg50558] Re: [mg50541] NestList > > g[x_] := Module[{}, > Print["Starting iteration #" <> ToString[n++]]; > Pause[1]; (* simulates long calculation *) > f[x]]; > > n=1;soln=NestList[g, x, 3] > > Starting iteration #1 > > Starting iteration #2 > > Starting iteration #3 > > {x, f[x], f[f[x]], f[f[f[x]]]} > > > Bob Hanlon > > > > > From: Namrata Khemka <namrata.khemka at gmail.com> To: mathgroup at smc.vnet.net > > Date: 2004/09/09 Thu AM 05:19:01 EDT > > To: mathgroup at smc.vnet.net > > Subject: [mg50558] [mg50541] NestList > > > > 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 > > > > >