Thanks for the report. Should be fixed in teh devel and 2.9 branches.
luke
On Mon, 1 Jun 2009, William Dunlap wrote:
It looks like the 'seq' variable to 'for' can be altered from
within the loop, leading to incorrect answers. E.g., in
the following I'd expect 'sum' to be 1+2=3, but R 2.10.0
William Dunlap wrote:
> It looks like the 'seq' variable to 'for' can be altered from
> within the loop, leading to incorrect answers. E.g., in
> the following I'd expect 'sum' to be 1+2=3, but R 2.10.0
> (svn 48686) gives 44.5.
>
>> x = c(1,2); sum = 0; for (i in x) { x[i+1] = i + 42.5; sum
It looks like the 'seq' variable to 'for' can be altered from
within the loop, leading to incorrect answers. E.g., in
the following I'd expect 'sum' to be 1+2=3, but R 2.10.0
(svn 48686) gives 44.5.
> x = c(1,2); sum = 0; for (i in x) { x[i+1] = i + 42.5; sum = sum +
i }; sum
[1] 44.5
or,