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

Evaluation in Iteration Functions

The built-in Mathematica iteration functions such as Table and Sum evaluate their arguments in a slightly special way.
When evaluating an expression like Table, the first step, as discussed in "Blocks and Local Values", is to make the value of i local. Next, the limit in the iterator specification is evaluated. The expression f is maintained in an unevaluated form, but is repeatedly evaluated as a succession of values are assigned to i. When this is finished, the global value of i is restored.
The function RandomReal is evaluated four separate times here, so four different pseudorandom numbers are generated.
Click for copyable input
This evaluates RandomReal before feeding it to Table. The result is a list of four identical numbers.
Click for copyable input
In most cases, it is convenient for the function f in an expression like Table to be maintained in an unevaluated form until specific values have been assigned to . This is true in particular if a complete symbolic form for f valid for any i cannot be found.
This defines to give the factorial when it has an integer argument, and to give (standing for "Not a Number") otherwise.
Click for copyable input
In this form, is not evaluated until an explicit integer value has been assigned to .
Click for copyable input
Using Evaluate forces to be evaluated with left as a symbolic object.
Click for copyable input
In cases where a complete symbolic form for f with arbitrary i in expressions such as Table can be found, it is often more efficient to compute this form first, and then feed it to Table. You can do this using Table[Evaluate[f], {i, imax}].
The Sum in this case is evaluated separately for each value of .
Click for copyable input
It is however possible to get a symbolic formula for the sum, valid for any value of .
Click for copyable input
By inserting Evaluate, you tell Mathematica first to evaluate the sum symbolically, then to iterate over .
Click for copyable input
Table[f,{i,imax}]keep f unevaluated until specific values are assigned to i
Table[Evaluate[f],{i,imax}]evaluate f first with i left symbolic

Evaluation in iteration functions.