newLISP Fan Club

Forum => newLISP newS => Topic started by: Lutz on January 07, 2008, 08:41:07 AM

Title: development release newLISP v.9.2.12
Post by: Lutz on January 07, 2008, 08:41:07 AM
Feature complete for 9.3 release on January 15th.



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



Lutz
Title:
Post by: cormullion on January 07, 2008, 11:34:51 AM
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) !



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...!)
Title:
Post by: newdep on January 08, 2008, 12:25:52 AM
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.
Title:
Post by: Cyril on January 08, 2008, 04:07:43 AM
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'?
Title:
Post by: Cyril on January 08, 2008, 04:12:41 AM
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.
Title:
Post by: newdep on January 08, 2008, 04:51:30 AM
Its still far from logic...
Title:
Post by: Lutz on January 08, 2008, 05:02:44 AM
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
Title:
Post by: cormullion on January 08, 2008, 10:32:54 AM
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!