【发布时间】:2021-08-19 10:54:03
【问题描述】:
我试图在 if-else 语句中使用 char 作为条件,但条件似乎只能接受整数输入。
这是我的代码:
(display "Presenter - R \nParticipant - P")
(define (option)
(define r(read))
(cond
((= r R )
(display "Presenter: \nLocal - RM1272\nInternational - RM1474"))
((= r P )
(display "Participant: \nLocal - RM795\nInternational - RM800"))
))
输出:
Presenter - R
Participant - P
> (option)
R
. . =: contract violation
expected: number?
given: r
【问题讨论】:
-
=仅适用于数字。您需要找到适用于更一般类型的谓词。 -
就用
equal? -
使用
equal?不起作用。
标签: if-statement char scheme racket