此为 Mathematica 4 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)

Fold

Usage

Fold[f, x, list]给出FoldList[f, x, list]的最后元素。


Notes

• 例如: Fold[f, x,  a, b, c ]LongRightArrow .
• 可以使用Throw在它被完成前从Fold退出
• 参见 FoldList的注解。
• 参见 Mathematica 全书 2.2.2.
• 同时参见: Nest.
Further Examples

(See the Further Examples for ReplacePart for a powerful application of Fold to partial evaluation of held expressions.)

Here is the result of folding the function f over the list {a,b,c} starting with x.

In[1]:=  

Out[1]=

Here is a definition of the factorial function in a functional style.

In[2]:=  

In[3]:=  

Out[3]=

In[4]:=  

Here is an implementation of Horner's rule.

In[5]:=  

Out[5]=