dangrous true?

Q&A's, tips, howto's
Locked
ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

dangrous true?

Post by ssqq »

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))

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

Re: dangrous true?

Post by rickyboy »

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)

Locked