Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have a list of RandomReal:

delta = RandomReal[{-0.01, 0.01}, 1000]

I want to add each element of the list to the corresponding result of a function iteration in my NestList, but I need some sort of index in the NestList.

I can't do it this way:

NestList[g[#, 3] + RandomReal[{-0.01, 0.01}] &, .5, 1000]

because the RandomReal list has to be predefined before calculating iterations.

What are my choices?

share|improve this question

marked as duplicate by Kuba, Artes, ciao, m_goldberg, Silvia Apr 1 '14 at 23:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

So FoldList seems the function you need. – Kuba Apr 1 '14 at 17:37

As Kuba said, FoldList is what I need:

FoldList[g[#1, 3] + #2 &, .5, delta]
share|improve this answer
Perhaps you would rather use Fold instead of FoldList. – Artes Apr 1 '14 at 17:49
Fold gives me the last item of FoldList if I understand correctly which is not what I need, because I have to ListPlot the thing after. – Egor N Apr 1 '14 at 20:11

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