Mathematica 9 is now available

Scan

Usage

Scan[f, expr] 依次把f 应用到expr的每个元素并对其进行计算.
Scan[f, expr, levelspec]f 应用到expr 中由levelspec指定的部分.


Notes

Scan[f, expr] 丢掉把 f 应用到expr中的子表达式得到的结果. 与 Map不同,Scan返回时不创建新的表达式.
• 你可以使用ReturnScan退出. Return[ret]使得Scan的最后值为ret. 如果不明确指定一个返回值,Scan的最后结果是Null.
• 你也可以使用ThrowScan退出.
Scan在对表达式的部分实现类似进行赋值这样一个具有"副作用"的操作是有用的.
• 层指定在A.3.6节中描述.
Scanlevelspec的缺省值为{1}.
• 参见Mathematica 全书: 2.2.4节.
• 同时参见: Apply, Map, Level.
Further Examples

Scan evaluates the result of applying a function to each element but does not construct a new expression.

In[1]:=  




With the third argument set to Infinity, Scan visits the parts of an expression in a depth-first walk, with the leaves visited first.

In[2]:=  











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.