【发布时间】:2020-09-16 19:57:54
【问题描述】:
我刚刚开始在 DrRacket 中编写方案。然而,就像我们都知道的那样,语法上的那些小变化总是把我们搞砸!
我相信我的错误在于和条件。如果有人可以看看并告诉我出了什么问题,那就太好了!
; in-range?: int int list of numbers --> boolean
(define in-range?
(lambda (a b s)
(cond [(null? s) #t] ;List is empty
[(null? a) #f]
[(null? b) #f]
[((and >= (car s)) ((a) <= (car s)) (b)) (in-range? (a) (b) (cdr s))]
[else #f]
)))
【问题讨论】:
-
我想知道为什么你有
null?检查a和b,因为签名说a和b是整数,而不是列表 -
如果它们是空的则返回 false,我在几分钟前意识到如果它们是空的,程序甚至都不会运行。