Page 1 of 1
development release newLISP v.9.2.12
Posted: Mon Jan 07, 2008 4:41 pm
by Lutz
Feature complete for 9.3 release on January 15th.
Files and changes notes:
http://newlisp.org/downloads/development/
Lutz
Posted: Mon Jan 07, 2008 7:34 pm
by cormullion
Thanks Lutz!
Yes, I'm now finding a few 'list index out of bounds' errors in my code - such as in my first effort at a tokenizer (
http://unbalanced-parentheses.nfshost.c ... er.lsp.txt) !
A virtual beer token to anyone who can find the out of bounds list index!
(I've always claimed to be a beginner, so it's good that newLISP 9.3 is picking up more of my beginner's errors than before...!)
Posted: Tue Jan 08, 2008 8:25 am
by newdep
Lutz,
Could "list index out of bounds" be changed into 'nil or an empty list?
This error message does not feel right in the newlisp context.
Lots of functions do return 'nil when nothing found..
so should indexes on lists. That makes programming more logical too.
...but thats my view...
Btw.. (10 '( 1 2 3)) still returns '().
Norman.
Posted: Tue Jan 08, 2008 12:07 pm
by Cyril
It seems that I found a bug: 'randomize' on 2-element list doesn't randomize it. List is always reversed, mo matter how much times do you call the function.
Code: Select all
> (randomize '(1 2))
(2 1)
> (randomize '(1 2))
(2 1)
> (randomize '(1 2))
(2 1)
Another related bug in documentation: in description of 'rand' function it said "When 0 (zero) is passed, the internal random generator is initialized using the current value returned by the
time function". But 'time' is of no use here! Probably 'time-of-day' or 'date-value'?
Posted: Tue Jan 08, 2008 12:12 pm
by Cyril
newdep wrote:Could "list index out of bounds" be changed into 'nil or an empty list?
This way you cannot distinguish between ('(a b c) 3) and ('(a b c nil) 3)
newdep wrote:Btw.. (10 '( 1 2 3)) still returns '().
Python does it exactly this way.
Posted: Tue Jan 08, 2008 12:51 pm
by newdep
Its still far from logic...
Posted: Tue Jan 08, 2008 1:02 pm
by Lutz
This is intended behavior, 'randomize' keeps trying until a different sequence is found. Pass the extra parameter 'true' to force true randomization.
Code: Select all
> (randomize '(1 2) true)
(2 1)
> (randomize '(1 2) true)
(1 2)
> (randomize '(1 2) true)
(2 1)
> (randomize '(1 2) true)
(2 1)
> (randomize '(1 2) true)
(2 1)
> (randomize '(1 2) true)
(2 1)
> (randomize '(1 2) true)
(1 2)
>
Lutz
ps: this is also described in the manual:
http://newlisp.org/downloads/newlisp_ma ... #randomize
Posted: Tue Jan 08, 2008 6:32 pm
by cormullion
I've found my bug, so I'm going to drink the beer myself... :)
should have been
I have no excuse, and it's an ugly fix anyway... :) Still, you're lucky I don't do this for a living!