Re: [Maxima] Bug in 'for', Maxima, Debian ?
On Wednesday 07 of July 2010 19:46:38 you wrote:
> Zbigniew Komarnicki escribió:
> > Hello,
> > I try to write fuction that return a list of number in range [a,b] with
> > step k, but first i try in command window this code:
> > /* This work in command window without variables */
> > kill(all);
> > m:;
> > for i:0 step -3 thru 10 do (m:append(m, [i]), display(i));
> > display(m);
> > Here is OK
> If you want to reach 10, shouldn't step be a positive number?
No, I try exactly from 0 to 10 with step -3. I know that it should be empty
list (empty matrix I got in octave, see below)
Form 0 to 10 with step 3 it work excellent - there is no problem.
(%i2) for i:0 step 3 thru 10 do (m:append(m, [i]), display(i))$
i = 0
i = 3
i = 6
i = 9
m = [0, 3, 6, 9]
The problem is when I go with 0 to 10 with -3 or in general when:
a < b and k is negative number.
In Octave I write something like:
From 0 to 10 with step -3 I got empty matrix in octave:
ans = (1x0)
I got empty matrix it is correct.
From 0 to 10 with step 3 I got as expected
0 3 6 9
I got results as expected.
The problem in Maxima is when we use variables:
and write the code:
for i:a step k thru b do (m:append(m, [i]), display(i))$
This loop shouldn't execute, but this loop go forever (!!!) writing: i=0,
i=-3, i=-6, ..., i=infinity, but when I write this same code with numbers in
the loop, it work as expected:
for i:0 step -3 thru 10 do (m:append(m, [i]), display(i))$
m = 
and the result is empty list m=.