5
$\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$
2
  • 1
    $\begingroup$ Try FoldList[STEP[#, #2] &, m0, Table[ii/NT, {ii, 1, NT}] ]? $\endgroup$
    – kglr
    Commented Jul 14, 2019 at 6:10
  • $\begingroup$ This worked like a charm ... Thank you ! $\endgroup$
    – anon248
    Commented Jul 14, 2019 at 6:40

1 Answer 1

7
$\begingroup$

You can use FoldList:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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