development release newLISP v.9.2.12

Notices and updates
Locked
Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

development release newLISP v.9.2.12

Post by Lutz »

Feature complete for 9.3 release on January 15th.

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

Lutz

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post 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...!)

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

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

Cyril
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia
Contact:

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

Cyril
Posts: 183
Joined: Tue Oct 30, 2007 6:27 pm
Location: Moscow, Russia
Contact:

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

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post 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

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

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

Code: Select all

(for (p 0 (length result))
should have been

Code: Select all

(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!

Locked