Anonymous user
Multiple distinct objects: Difference between revisions
→{{header|Mathematica}}
Line 347:
for (var i = 0; i < n; i++)
a[i] = new Foo();</lang>
=={{header|Mathematica}}==
<lang Mathematica>The mistake is often written as:
{x, x, x, x} /. x -> Random[] # here Random[] can be any expression that returns a new value
which is incorrect since Random[] is only evaluated once. e.g.
{0.175125, 0.175125, 0.175125, 0.175125}
A correct version is:
{x, x, x, x} /. x :> Random[]</lang>
which evaluates Random[] each time e.g.
->{0.514617, 0.0682395, 0.609602, 0.00177382}
=={{header|Modula-3}}==
|