scheme - scheme - 球拍:預期:過程?

  显示原文与译文双语对照的内容

我有以下代碼:


(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)



时间:

我有以下代碼:


(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)



...