Common Lisp 中的 Corece 到布尔值

Corece to boolean in Common Lisp

Common Lisp 中是否有一个内置函数可以将任何东西强制转换为它的布尔值,就像 Python 中的 bool 函数一样?

有点。如果 form 不是错误值 nil().

之一,(and form t) 将 return t

它是一个宏,而不是一个函数,它需要额外的参数t来完成这个技巧。

没有专门针对此的内容。您不能使用 boolean 作为 coerce 的类型参数。您可以使用:

(defun boolean-value (x)
  (not (not x)))

这类似于许多其他语言中使用的 !!x 成语。