This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

FoldList

FoldList
gives .
  • FoldList[Plus, 0, list] generates cumulative sums of the elements in list.
  • With a length n list, FoldList generates a list of length . »
Cumulative sums of the elements of the list:
Cumulative powers:
In[1]:=
Click for copyable input
Out[1]=
 
Cumulative sums of the elements of the list:
In[1]:=
Click for copyable input
Out[1]=
 
Cumulative powers:
In[1]:=
Click for copyable input
Out[1]=
The head need not be List:
Fold to the right:
Compute successive factorials:
Compute products of successive primes:
Cumulative sums:
Build up a continued fraction:
Build up a nested polynomial (Horner form):
Build up a number from digits:
Form alternating sums:
Generate a random walk:
Find the running maximum of a list:
Find successively deeper parts in an expression:
Successively append to a list:
Build up a binary tree:
Build up a left-branching binary tree:
Make function compositions:
Compute a power using a power tree with successive squaring:
FoldList makes a list of length :
Rest gives a result of length :
Folding with an empty list does not apply the function at all:
Fold gives the last element of FoldList:
Functions that ignore their second argument give the same result as in NestList:
Accumulate is equivalent to FoldList with Plus:
Compute the minimum number of coins of different value needed to make up an amount :
New in 2