我有以下代码:
(define numbers '(2 3 5 3 1 22 2))
(define (count val l)
(if (null? l)
0
(+
(if (= (first l) val) 1 0)
(count val (rest l))
)
)
)
(display (count 6 numbers))
Run Code Online (Sandbox Code Playgroud)
(对不起,如果我的代码看起来很糟糕,只需要使用这种语言一次)
编译器说:
count: contract violation
expected: procedure?
given: 6
argument position: 1st
other arguments...:
'(3 5 3 1 22 2)
Run Code Online (Sandbox Code Playgroud)