(lookup nil x) -> 1st item?

Q&A's, tips, howto's
Locked
kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

(lookup nil x) -> 1st item?

Post 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.
. Kanen Flowers http://kanen.me .

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

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

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

Locked