我开始学习 Scheme,我正在尝试实现我自己的 max 函数,它只给出两个参数的最大值。
我写了这样的函数:
(define (myMax x y) (cond ((> x y) (x)) ((< x y) (y))))
但是每次我尝试调用它(myMax 100 40)
(示例)时,我都会收到一条错误消息:
The object 100 is not applicable.
搜索 GNU 的 MIT-Scheme 的文档,他们说:
This type indicates an error in which a program attempted to apply an object that is not a procedure. The object being applied is saved in the datum field, and the arguments being passed to the object are saved as a list in the operands field.
但这应该是什么意思?
奇怪的是,我实现了一个非常简单的函数,将两个数字相加,它工作得很好,一个绝对值函数也工作得很好;可能是条件搞砸了?
谢谢