gpt4 book ai didi

lisp - 和运算符 Lisp

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

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

当我尝试以下示例时 -

(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/

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