gpt4 book ai didi

boolean 运算

转载 作者:太空宇宙 更新时间:2023-11-03 18:50:58 27 4
gpt4 key购买 nike

为什么 (defun boolimplies (a b) (or (not a) b)) if called as(boolimplies 'a 'b) 返回 B?

即使我不使用任何 boolean 值 (NIL,T) 而只使用变量名,它是如何得出这个结论的?

最佳答案

虽然在 Common Lisp 中只有 tnil 是 boolean 值,但也有 generalized booleans.即所有对象都可以作为真值,只有符号nil为假。您正在传递 nil 以外的符号,它们是真实的。

(只是为了避免任何潜在的混淆:如果您有变量 ab 并且想使用它们的值而不是符号,只需将它们不加引号即可。)

关于 boolean 运算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31911953/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com