"logo.gif"  
Main
Read Online
Download PDF
Additional resources
Revision history
Known typos/bugs
Report a bug
License terms
About the author
"node98_1.gif" "node98_2.gif" "node98_3.gif"

2.4.2      The difference between Set and SetDelayed : an example

Here is an example:

"node98_4.gif"

"node98_5.gif"

"node98_6.gif"

"node98_7.gif"

"node98_8.gif"

"node98_9.gif"

"node98_10.gif"

"node98_11.gif"

"node98_12.gif"

"node98_13.gif"

"node98_14.gif"

"node98_15.gif"

In both cases, an object (a or b) is assigned a random integer in the range 1 -10. But in the former case, it is computed at the moment of assignment and then is attached to <a>, while in the latter case it is recomputed afresh every time that b is called. We have also used one of the looping constructs Do, which we will cover shortly.

"node98_16.gif" "node98_17.gif" "node98_18.gif"

Created by Wolfram Mathematica 6.0  (05 February 2009) Valid XHTML 1.1!