development release newLISP v.9.2.12

Started by Lutz, January 07, 2008, 08:41:07 AM

Previous topic - Next topic

Lutz

Feature complete for 9.3 release on January 15th.



Files and changes notes: http://newlisp.org/downloads/development/">http://newlisp.org/downloads/development/



Lutz

cormullion

#1
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.com/syntax.cgi?downloads/tokenizer.lsp.txt">//http://unbalanced-parentheses.nfshost.com/syntax.cgi?downloads/tokenizer.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...!)

newdep

#2
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.
-- (define? (Cornflakes))

Cyril

#3
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.


> (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'?
With newLISP you can grow your lists from the right side!

Cyril

#4
Quote from: "newdep"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)


Quote from: "newdep"Btw.. (10 '( 1 2 3)) still returns  '().


Python does it exactly this way.
With newLISP you can grow your lists from the right side!

newdep

#5
Its still far from logic...
-- (define? (Cornflakes))

Lutz

#6
This is intended behavior, 'randomize' keeps trying until a different sequence is found. Pass the extra parameter 'true' to force true randomization.





> (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_manual.html#randomize">http://newlisp.org/downloads/newlisp_ma ... #randomize">http://newlisp.org/downloads/newlisp_manual.html#randomize

cormullion

#7
I've found my bug, so I'm going to drink the beer myself... :)


(for (p 0 (length result))

should have been


(for (p 0 (- (length result) 2))

I have no excuse, and it's an ugly fix anyway... :) Still, you're lucky I don't do this for a living!