【发布时间】:2025-12-01 15:25:01
【问题描述】:
最近,我正在学习 scp,但我遇到了一个奇怪的问题:
Error: remainder: contract violation expected: integer? given: '(3 4 5 6) argument position: 1st other arguments...: 2
这是我的代码
(define (same-parity sample . other)
(if (null? other)
(cons sample '())
(if (= (remainder sample 2) (remainder (car other) 2))
(cons (car other) (same-parity sample (cdr other)))
(same-parity sample (cdr other)))))
(same-parity 1 2 3 4 5 6)
- 操作系统:win10
- lang: 球拍 v6.10.1
它告诉余数期望一个整数参数 我想我给了一个整数,而不是一个列表。所以有人可以告诉我我的代码有什么问题。我陷入了困境。提前致谢。
【问题讨论】: