Jon Perry on Thu, 19 Jun 2003 16:22:27 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Vector bug


? a=[1]
%57 = [1]
? a=vector(100,i,a[1]+1)
%58 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2
, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2,
 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
?

By my reckoning, when i=1, a[1] becomes 2, and so by i=2, a[2] should be
evaluated using the most current a[1] value, i.e. 2, so the vector returned
should be [2, 3, 3, ...].

This is more annoying in;

a=concat([1,2],vector(100,i,if (i>2,a[i-1]+a[i-2],a[i])))

which using my logic would produce the Fibonacci sequence.

Jon Perry
perry@globalnet.co.uk
http://www.users.globalnet.co.uk/~perry/maths/
http://www.users.globalnet.co.uk/~perry/DIVMenu/
BrainBench MVP for HTML and JavaScript
http://www.brainbench.com