Reputation:
Is there a build-in function in Common Lisp to coerce any thing into it's boolean value, like the bool
function in Python does?
Upvotes: 5
Views: 1268
Reputation: 781300
There's nothing specifically for this. You can't use boolean
as the type argument to coerce
. You can use:
(defun boolean-value (x)
(not (not x)))
This is analogous to the !!x
idiom used in many other languages.
Upvotes: 8
Reputation: 6315
Sort of. (and form t)
will return t
if form
is not one of the false values nil
or ()
.
I.e. it is a macro, not a function, and it requires the additional argument t
to do the trick.
Upvotes: 3