4
$\begingroup$

I have a NestList construction

NestList[STEP[#] &, m0, NT]

where a function is being called repeatedly that acts on a list and returns a list, for details, see here.

Let NT in the NestList denote a discrete time, and let's say I'd like to have a parameter that is passed to the STEP function as a function of discrete time.

In other words, I'd like to pass a parameter temperature that's like:

temperature = Table[ii/NT,{ii,1,NT}] 

to my STEP function through NestList.

I am sure there is an easy way to do this, but I can't seem to figure it out.

$\endgroup$
  • 1
    $\begingroup$ Try FoldList[STEP[#, #2] &, m0, Table[ii/NT, {ii, 1, NT}] ]? $\endgroup$ – kglr Jul 14 '19 at 6:10
  • $\begingroup$ This worked like a charm ... Thank you ! $\endgroup$ – YNSBRYR Jul 14 '19 at 6:40
7
$\begingroup$

You can use FoldList:

FoldList[STEP[#, #2] &, m0, Table[ii/NT, {ii, 1, NT}] ]
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.