MathGroup Archive 2004

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

Search the Archive

Re: NestList


You need to carry the counter along as part of the nesting process.

For instance

NestList[{#1[[1]] + 1, function[#1[[2]]]} & , {0, expr}, 5]

gives

{{0, expr},{1, function[expr]}, {2, function[function[expr]]}, {3, 
function[function[function[expr]]]}, {4,
function[function[function[function[expr]]]]}, {5, 
function[function[function[function[ function[expr]]]]]}}

Steve Luttrell

"Namrata Khemka" <namrata.khemka at gmail.com> wrote in message 
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
> 



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