Scheme 获取错误不是函数

Scheme getting error is not a function

,我正在用 Scheme 做作业。我正在使用 Scheme MIT Interpreter 和 https://repl.it/languages/scheme 来测试我的代码。

第一个问题是

; - 在?过程采用元素“el”和列表“lst”。 ; - 它 returns 一个布尔值。 ; - 当 el 在 lst 中时 returns 为真,否则 returns 为假。 ; - 例子: ; (在?3'(2 5 3)) ;评估为#t ; (在?2'(1(2)5)) ;评估为#f ; - 如果 lst 不是一个列表,它会产生一个错误..

我的密码是

(define lst())
(define el())

(define in? (lambda (el lst)
    (if(null? lst) 
        #f
 (if (eq? (car lst el ))
    #t
   (in? el cdr lst )))
(error "ERROR")))

(in? 3'(2 5 3))

我在下面的 MIT Interpreter 中遇到错误

The procedure #[compiled-procedure 13 ("global" #x14) #x14 #x2620cd4] has been called with 3 arguments; it requires exactly 2 arguments. ;To continue, call RESTART with an option number: ; (RESTART 1) => Return to read-eval-print level 1.

当我在 https://repl.it/languages/scheme

中测试它时

我遇到了类似

的错误

Error: 2 is not a function [(anon)]

为什么我会收到这些错误?

试试这个:

(define in? 
  (lambda (el lst)
    (if (or (null? lst) (pair? lst))
        (if (null? lst) 
            #f
            (if (equal? (car lst) el )
                #t
                (in? el (cdr lst))))
        (error "ERROR"))))

通常的提示适用:注意括号,正确缩进代码,使用 equal? 进行相等比较,注意测试参数是否为列表的正确方法并确保您了解如何将参数传递给过程以及如何实际 调用 过程。它现在按预期工作:

(in? 1 '(2 5 3))
=> #f
(in? 3 '(2 5 3))
=> #t
(in? 1 5)
=> ERROR