(float) with elements of the list

Q&A's, tips, howto's
Locked
denis
Posts: 20
Joined: Wed Apr 27, 2011 12:19 pm
Location: Petsamo, Murmansk, RU

(float) with elements of the list

Post by denis »

Some strange behavior:

Code: Select all

(set 'lst '("23" "hello" "3.14"))
(float (lst 1))
; -> "3.14" instead of nil
Why so?

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

Re: (float) with elements of the list

Post by cormullion »

Code: Select all

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

> (set 'lst '("23" "hello" "3.14"))
("23" "hello" "3.14")
> (float (lst 1))
nil
> 
and

Code: Select all

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

> (set 'lst '("23" "hello" "3.14"))
("23" "hello" "3.14")
> (float (lst 1))
"3.14"
> 
indicate some kind of regression over the last year. I haven't got the intermediate versions here to test when this happened...

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: (float) with elements of the list

Post by rickyboy »

I get the same thing on 10.4.1. But note that (lst 1) returns "hello", as expected.

Code: Select all

newLISP v.10.4.1 on Win32 IPv4/6 libffi, execute 'newlisp -h' for more info.

> (set 'lst '("23" "hello" "3.14"))
("23" "hello" "3.14")
> (float (lst 1))
"3.14"
> (lst 1)
"hello"
Good catch, denis.
(λx. x x) (λx. x x)

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: (float) with elements of the list

Post by jopython »

Same issue on my Linux desktop.

Code: Select all

newLISP v.10.4.3 on Linux IPv4/6 UTF-8 libffi, execute 'newlisp -h' for more info.
> (set 'lst '("23" "hello" "3.14"))
("23" "hello" "3.14")
> (float (lst 1))
"3.14"

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

Re: (float) with elements of the list

Post by Lutz »

This is a bug in the 'float' function when using it on list elements, introduced in a development release before 10.4.0 and is fixed now in 10.4.5 in progress:

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

I will do a maintenance release as soon as I am back in the US next week, probably on the 15th of November.

Locked