MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NestList

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50556] Re: [mg50541] NestList
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 10 Sep 2004 04:05:54 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

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: [mg50556] [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
> 
> 


  • Prev by Date: Re: NestList
  • Next by Date: Re: NestList
  • Previous by thread: Re: NestList
  • Next by thread: Re: NestList