Page 1 of 1

(lookup nil x) -> 1st item?

Posted: Sat Jan 29, 2011 2:02 am
by kanen
Try this:

Code: Select all

> (set 'tr '( (1 "foo") (2 "bar") (3 "baz")))
((1 "foo") (2 "bar") (3 "baz"))
> (lookup nil tr)
"foo"
Unless I'm missing something, shouldn't (lookup) return nil?

By the way, I got here because I'm actually doing:

Code: Select all

(lookup x tr)
And x can be nil.

Re: (lookup nil x) -> 1st item?

Posted: Sat Jan 29, 2011 1:04 pm
by Lutz
This is fixed in the upcoming stable version 10.3.0. There is a preview here:

http://www.newlisp.org/downloads/develo ... nprogress/

Note, that I could only reproduce the first case in your post, not the second case where a key variable x is set to nil, where it worked correctly for me.

In upcoming 10.3.0 nil is a legitimate lookup item:

Code: Select all

newLISP v.10.3.0 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.

> (set 'tr '( (1 "foo") (nil "bar") (3 "baz")))
((1 "foo") (nil "bar") (3 "baz"))
> (lookup nil tr)
"bar"
> 
the second sublist contains nil in the lookup position.