filter or find-all different results w/ diff nL versions

Q&A's, tips, howto's
Locked
joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

filter or find-all different results w/ diff nL versions

Post by joejoe »

Hi -

When I try this on my computer, it works fine:

newLISP v.10.3.3 on Linux IPv4/6 UTF-8

Code: Select all

(set 'a '("oneone" "two" "twotwotwo" "three" "threethree"))
(println (filter (fn (x) (find-all {\w{6,12}} x)) a))
;-> ("oneone" "twotwotwo" "threethree")

but when I try on NearlyFreeSpeech.net

newLISP v.10.2.8 on BSD IPv4 UTF-8

Code: Select all

(set 'a '("oneone" "two" "twotwotwo" "three" "threethree"))
(println (filter (fn (x) (find-all {\w{6,12}} x)) a))
;-> ("oneone" "two" "twotwotwo" "three" "threethree")

As the code shows, Im after strings 6-12 characters long.

Am I missing something or is there a slight difference causing this from nL 10.2.8 to 10.3.3?

Thanks very much in advance! :)

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

Re: filter or find-all different results w/ diff nL versions

Post by Lutz »

Empty lists () are treated differently by all filtering functions starting in 10.3.2. The following code gives the same result on all versions.

Code: Select all

(set 'a '("oneone" "two" "twotwotwo" "three" "threethree"))

(filter (fn (x) (regex {\w{6,12}} x)) a) ;=> ("oneone" "twotwotwo" "threethree")

; or shorter

(filter (curry regex {\w{6,12}}) a) ;=>  ("oneone" "twotwotwo" "threethree")

joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Re: filter or find-all different results w/ diff nL versions

Post by joejoe »

Thanks Lutz!

I grazed through the release notes but perhaps a little too fast.

Thanks for the cross version examples and explanation!

Ive been looking for a way to try out the curry. ;0)

winger
Posts: 46
Joined: Wed Mar 14, 2012 7:31 am

Re: filter or find-all different results w/ diff nL versions

Post by winger »

Very strange!
NewLISP v.9.2.0 is no problem!

Many problems are caused by the return value.
Does not detect the type or null '() null ...
And the manual did not specifically label the return value.
Welcome to a newlisper home:)
http://www.cngrayhat.org

Locked