Page 1 of 1

dangrous true?

Posted: Wed Jul 27, 2016 12:32 pm
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))

Re: dangrous true?

Posted: Fri Aug 05, 2016 12:26 pm
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".