我有以下代码:
(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))
(对不起,如果我的代码看上去很糟糕,只需要使用这种语言一次)
编译器说:
count: contract violation
expected: procedure?
given: 6
argument position: 1st
other arguments...:
'(3 5 3 1 22 2)
您正在交互区域中输入代码。
不要。在源代码区域中输入它,然后加载它。然后就可以了。