This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Programming / Functional Programming  /
FoldList

  • FoldList[ f , x , a , b , ... ] gives x , f [ x , a ], f [ f [ x , a ], b ], ... .
  • Example: FoldList[f, x, a, b, c ].
  • FoldList[Plus, 0, list ] generates cumulative sums of the elements in list.
  • Example: FoldList[Plus, 0, a, b, c ].
  • With a length list, FoldList generates a list of length .
  • The head of list in FoldList[ f , x , list ] need not be List.
  • See the Mathematica book: Section 2.2.2.
  • See also: NestList, ComposeList, Partition, MapIndexed.

    Further Examples

    This gives a list of cumulative sums.

    In[1]:=

    Out[1]=

    For the cumulative products you have to start with .

    In[2]:=

    Out[2]=