mardi 1 juin 2021

Condition using char in Scheme

I'm trying to use char as a condition in my if-else statement but it seems the condition only can accept integer input.

This is my code:

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

Output:

Presenter - R 
Participant - P
> (option)
R
. . =: contract violation
  expected: number?
  given: r 

Aucun commentaire:

Enregistrer un commentaire