Mathematica 9 is now available

Block

Usage

Block[ x, y, ...  , expr] 指明expr使用符号 x, y, ...的局部值进行计算。
Block[ x =  , ...  , expr] 定义了 x, ... 的初始局部值。


Notes

Block 允许设置一个环境,在这个环境中,变量的值可以临时改变。
• 执行一个块时,分配给 x, y, ...的值被清除。块的执行结束时,这些符号的初始值被重新存储。
Block 仅对符号值有效,而对他们的名字无效。
• 指定的x, y, ... 的初始值在 x, y, ... 被清除之前求值。
• You can use Block[ vars , body /; cond] as the right-hand side of a transformation rule with a condition attached.
Block 有属性HoldAll.
Block 实现变量范围动态化。
Block 自动用于局部化如Do, SumTable迭代结构中的迭代子的值。
• 参见 Mathematica 全书: 2.6.6.
• 同时参见: Module, With, CompoundExpression.
Further Examples

Here is an expression involving x.

In[1]:=  

Out[1]=

This evaluates the previous expression, using a local value for x.

In[2]:=  

Out[2]=

There is no global value for x.

In[3]:=  

Out[3]=



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.