This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

true function

4 posts · 3555 views

Hi,

is there a "true" function in Common Lisp ?
I mean does there exist a function that returns t for all non nil values of its argument,
and nil if its argument is nil?

There are at least two "false" functions, not and null, which are strictly equivalent, but I was not able
to locate a "true" function. Some context: i want to write an expression that takes a list as its argument,
returns t if there is a non-nil element in the list, and nil otherwise. Here is what I have at the moment.
(notevery 'not list)
The not-not looks weird though. With a true function, I could write (some 'true list), which seems cleaner.

Re: true function

(some 'identity list) ?

Re: true function

This does not give exactly the same result.
CL-USER> (some 'identity (list nil "no" nil))
=> "no"
CL-USER> (notevery 'not (list nil "no" nil))
=> T
So I guess there is no builtin true function.
Anyway, thanks for the answer.

Re: true function

It doesn't mind because in CL everything is a true value but nil.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.