0

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?

Tim Chan
  • 11
  • 2

1 Answers1

0

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

amalloy
  • 89,153
  • 8
  • 140
  • 205
  • Thank you. The second call was missing an argument. Actually I just checked where the first call. I wrote this code in vscode, can't do the syntax check before execution, is there a better editor or IDE? – Tim Chan Jan 14 '21 at 07:33
  • @TimChan The syntax is correct - if it weren't, your interpreter would have rejected the code without executing it. The issue is semantics. – molbdnilo Jan 14 '21 at 15:48