PRODUCTS
Products Overview
Mathematica
Mathematica Student Edition
Mathematica Home Edition
Wolfram
CDF Player
(free download)
Computable Document Format (CDF)
web
Mathematica
grid
Mathematica
Wolfram
Workbench
Wolfram
SystemModeler
Wolfram
Finance Platform
Mathematica
Add-Ons
Wolfram|Alpha Products
SOLUTIONS
Solutions Overview
Engineering
Aerospace Engineering & Defense
Chemical Engineering
Control Systems
Electrical Engineering
Image Processing
Industrial Engineering
Materials Science
Mechanical Engineering
Operations Research
Optics
Petroleum Engineering
Biotechnology & Medicine
Bioinformatics
Medical Imaging
Finance, Statistics & Business Analysis
Actuarial Sciences
Data Analysis & Mining
Econometrics
Economics
Financial Engineering & Mathematics
Financial Risk Management
Statistics
Software Engineering & Content Delivery
Authoring & Publishing
Interface Development
Software Engineering
Web Development
Science
Astronomy
Biological Sciences
Chemistry
Environmental Sciences
Geosciences
Social & Behavioral Sciences
Design, Arts & Entertainment
Game Design, Special Effects & Generative Art
Education
STEM Education Initiative
Higher Education
Community & Technical College Education
Primary & Secondary Education
Students
Technology
Computable Document Format (CDF)
High-Performance & Parallel Computing (HPC)
See Also: Technology Guide
PURCHASE
Online Store
Other Ways to Buy
Volume & Site Licensing
Contact Sales
Software
Service
Upgrades
Training
Books
Merchandise
SUPPORT
Support Overview
Mathematica
Documentation
Knowledge Base
Learning Center
Technical Services
Community & Forums
Training
Does My Site Have a License?
Wolfram User Portal
COMPANY
About Wolfram Research
News
Events
Wolfram Blog
Partnerships
Employment Opportunities
History of
Mathematica
Stephen Wolfram's Home Page
Contact Us
OUR SITES
All Sites
Wolfram|Alpha
Demonstrations Project
MathWorld
Integrator
Wolfram Functions Site
Mathematica Journal
Wolfram Media
Wolfram
Tones
Wolfram Science
Stephen Wolfram
SEARCH MATHEMATICA 8 DOCUMENTATION
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE
DOCUMENTATION CENTER
FOR THE LATEST INFORMATION.
Mathematica
>
Core Language
>
List Manipulation
>
Applying Functions to Lists
>
Mathematica
>
Data Manipulation
>
Handling Arrays of Data
>
Applying Functions to Lists
>
Built-in
Mathematica
Symbol
Applying Functions Repeatedly
Tutorials »
|
Fold
Accumulate
Differences
Ratios
NestList
ComposeList
ExponentialMovingAverage
Partition
MapIndexed
See Also »
|
Applying Functions to Lists
Functional Iteration
Functional Programming
Language Overview
List Manipulation
More About »
FoldList
FoldList
[
f
,
x
, {
a
,
b
,
...
}]
gives
{
x
,
f
[
x
,
a
],
f
[
f
[
x
,
a
],
b
],
...
}
.
MORE INFORMATION
FoldList
[
Plus
, 0,
list
]
generates cumulative sums of the elements in
list
.
With a length
n
list,
FoldList
generates a list of length
.
»
The head of
list
in
FoldList
[
f
,
x
,
list
]
need not be
List
.
EXAMPLES
CLOSE ALL
Basic Examples
(3)
Cumulative sums of the elements of the list:
Cumulative powers:
In[1]:=
Out[1]=
Cumulative sums of the elements of the list:
In[1]:=
Out[1]=
Cumulative powers:
In[1]:=
Out[1]=
Generalizations & Extensions
(2)
The head need not be
List
:
Fold to the right:
Applications
(15)
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:
Properties & Relations
(5)
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
:
Neat Examples
(1)
Compute the minimum number of coins of different value needed to make up an amount
:
SEE ALSO
Fold
Accumulate
Differences
Ratios
NestList
ComposeList
ExponentialMovingAverage
Partition
MapIndexed
TUTORIALS
Applying Functions Repeatedly
MORE ABOUT
Applying Functions to Lists
Functional Iteration
Functional Programming
Language Overview
List Manipulation
RELATED LINKS
Demonstrations with FoldList
(
Wolfram Demonstrations Project
)
NKS|Online
(
A New Kind of Science
)
New in 2