schemechez-scheme

Scheme procedure exception about: incorrect number of arguments


I am a new schemer. Maybe this question is so easy. But it really bothers me.

I defined a procedure

(define insertL
    (lambda (new old lat)
      (cond
        ((null? lat) '())
        ((eq? old (car lat)) (cons new lat))
        (else (cons (car lat) (insertL (cdr lat)))))))

then I call it

> (insertL 2 3 '(1 2 3))

Exception occurred

Exception: incorrect number of arguments to #<procedure insertL>

Why?


Solution

  • How many arguments does insertL take? Are you calling it with the right number of arguments in both places that you call it?