Jump to content

Multiple distinct objects: Difference between revisions

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}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.