dangrous true?

Q&A's, tips, howto's

dangrous true?

Postby ssqq » Wed Jul 27, 2016 12:32 pm

if you use true? as checking function for list, be attention to: blank list -> '(), would not match it.

Code: Select all

> (true? '())
nil



If you often use it, advise you use :

Code: Select all
> (define (bool x) (if (nil? x) nil true))
> (for-all bool '(1 2 3 4 () 6))
ssqq
 
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Re: dangrous true?

Postby rickyboy » Fri Aug 05, 2016 12:26 pm

ssqq wrote:if you use true? as checking function for list, be attention to: blank list -> '(), would not match it.

Code: Select all

> (true? '())
nil

`true?` works as advertised.

http://www.newlisp.org/downloads/newlis ... html#truep

I don't see any problem with it, and so I don't consider it "dangerous".
(λx. x x) (λx. x x)
rickyboy
 
Posts: 595
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron