This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Block

Block
specifies that expr is to be evaluated with local values for the symbols x, y, ....
Block
defines initial local values for x, ....
  • Block allows you to set up an environment in which the values of variables can temporarily be changed.
  • When you execute a block, values assigned to x, y, ... are cleared. When the execution of the block is finished, the original values of these symbols are restored.
  • Block affects only the values of symbols, not their names.
  • Initial values specified for x, y, ... are evaluated before x, y, ... are cleared.
  • You can use Block as the right-hand side of a transformation rule with a condition attached.
  • Block implements dynamic scoping of variables.
  • Block is automatically used to localize values of iterators in iteration constructs such as Do, Sum, and Table.
Temporarily change settings of global system parameters:
Evaluate an expression with a variable temporarily set to a given value:
Perform a deeply recursive calculation:
The default setting of $RecursionLimit is too low for this calculation:
Use a local expression to visualize a complex map:
Block localizes values only; it does not create new symbols:
Module creates new symbols:
Iterators localize their variable in a similar way to Block:
New in 1