lisp - 和运算符 Lisp

标签 lisp common-lisp

为什么运算符会返回一个值?返回值取决于什么?

当我尝试以下示例时 -

(write (and a b c d)) ; prints the greatest integer among a b c d

其中abcd为正整数,则 code> 返回其中最大的一个。

但是当abcd其中之一为0或负数时,则取最小的返回整数。为什么会这样?

最佳答案

documentation 中所述:

The macro and evaluates each form one at a time from left to right. As soon as any form evaluates to nil, and returns nil without evaluating the remaining forms. If all forms but the last evaluate to true values, and returns the results produced by evaluating the last form. If no forms are supplied, (and) returns t.

因此返回值不取决于参数中“最大”或“最小”的值。

关于lisp - 和运算符 Lisp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33851885/

相关文章:

garbage-collection - 哈希表疑似SBCL垃圾回收Bug

common-lisp - 错误: Unbound variable: *AJAX-PROCESSOR* using HT-SIMPLE-AJAX

performance - Common Lisp,尤其是SBCL中线性代数的高效向量运算?

common-lisp - 常见的 LISP : convert (unknown) struct object to plist?

tree - 打开音乐 : L-System tree generation using lisp

lisp - 在 Lisp 中,为什么我们需要使用列表函数来返回列表?

LISP:为什么我不能在空列表上使用 cons?

lisp - 大象数据库

java - 主类的 Java 表达式错误中的 LISP 评估

list - lisp 中以特定方式显示列表的函数