newLISP Fan Club

Forum => newLISP in the real world => Topic started by: joejoe on June 26, 2012, 11:35:48 PM

Title: filter or find-all different results w/ diff nL versions
Post by: joejoe on June 26, 2012, 11:35:48 PM
Hi -



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



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


(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


(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! :)
Title: Re: filter or find-all different results w/ diff nL versions
Post by: Lutz on June 27, 2012, 09:13:28 AM
Empty lists () are treated differently by all filtering functions starting in 10.3.2. The following code gives the same result on all versions.


(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")
Title: Re: filter or find-all different results w/ diff nL versions
Post by: joejoe on June 27, 2012, 12:49:44 PM
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)
Title: Re: filter or find-all different results w/ diff nL versions
Post by: winger on June 30, 2012, 07:30:18 AM
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.