MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Is this a bug?


Your problem is with a[Random[Integer{0,1}]]++ :
It is interpreted as a[Random[Integer{0,1}]]=a[Random[Integer{0,1}]]+1
and therefore some of the times the loop transfers the value of one
register to the other (plus 1). In that case the combined value can
drop or rise by more than 1 -- hence you do not have a total sum of
50.
Mathematica is not C! Increment (++) has attribute HoldFirst,
therefore its argument (a[Random...] in this case) is evaluated ONLY
after arg++ has been replaced by arg=arg+1. Therefore this behaviour
is completely normal..
Orestis


  • Prev by Date: Re: NDSolve problem with piecewise functions
  • Next by Date: Re: Replacement Rule
  • Previous by thread: Re: Is this a bug?
  • Next by thread: Re: Re: Is this a bug?