nil?
Posted: Sun Sep 21, 2008 4:39 am
How do you remove a nil from a list?
Friends and Fans of newLISP
http://www.newlispfanclub.alh.net/forum/
http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=16&t=2460
Code: Select all
> (clean nil? '(1 2 3 nil 4))
(1 2 3 4)
Code: Select all
> box
("" nil "" "sdc1" "sda1" "sda2" "sdb2" "sdb1")
> (clean nil? box)
("" "" "sdc1" "sda1" "sda2" "sdb2" "sdb1")
> (clean empty? box)
ERR: list or string expected in function empty? : nil
>
Code: Select all
> (set 'box2 (clean nil? box))
("" "" "sdc1" "sda1" "sda2" "sdb2" "sdb1")
> (clean empty? box2)
("sdc1" "sda1" "sda2" "sdb2" "sdb1")
>
Code: Select all
> (set 'box '("" nil "" "sdc1" "sda1" "sda2" "sdb2" "sdb1"))
("" nil "" "sdc1" "sda1" "sda2" "sdb2" "sdb1")
> (clean empty? (clean nil? box))
("sdc1" "sda1" "sda2" "sdb2" "sdb1")
> _
Code: Select all
> (set 'box '("" nil "" "sdc1" "sda1" "sda2" "sdb2" "sdb1") )
("" nil "" "sdc1" "sda1" "sda2" "sdb2" "sdb1")
> (clean (fn (e) (or (nil? e) (empty? e))) box)
("sdc1" "sda1" "sda2" "sdb2" "sdb1")
>
Code: Select all
> (set 'box '("" nil "" "sdc1" "sda1" "sda2" "sdb2" "sdb1"))
("" nil "" "sdc1" "sda1" "sda2" "sdb2" "sdb1")
> (clean null? box)
("sdc1" "sda1" "sda2" "sdb2" "sdb1")
>
Thanks for pointing out 'null?' As you know, I've read the entire user's guide more than once, but didn't recall 'null?'Lutz wrote:Or use 'null?' which checks for the nil, the empty list (), the empty string "" and 0 and 0.00 and NaN.
Ah, maybe I missed it becasue I'm not used to seeing alphabetical ordering such ascormullion wrote:It's hidden between now and nper... :)
This would help to find the queue jumpers, but I think the original is not HTML...?DrDave wrote:Ah, maybe I missed it becasue I'm not used to seeing alphabetical ordering such ascormullion wrote:It's hidden between now and nper... :)
'npv'
'nth'
'null?'
'nper' <---(how did this guy cut in line here??)
'number?'
Code: Select all
(set 'file (read-file "/usr/share/doc/newlisp/newlisp_manual.html"))
(set 'data (find-all (string {<h2><span class="function">([a-z].*?)</span></h2>}) file $1))
(map (fn (x y)
(if (!= x y)
(println (format { ? %-18s should be %-18s } x y))
(println (format { %-18s %-18s } x y))))
data
(sort data))
.....
nil? nil?
? not should be normal
? normal should be not
now now
? null? should be nper
? nper should be npv
? npv should be nth
? nth should be null?
number? number?
.....