Mathematica 9 is now available

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]=



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.