I'm playing around with Scheme (though restricted to the lisp aspects for the assignment that I'm preparing for) and I'm trying to figure out how to perform an "if/else-if/else" using cond
in Scheme. How would I implement something like
public void check(char symbol)
{
if(symbol == 'a')
{
System.out.println("a");
}
else if(symbol == 'b')
{
System.out.println("b");
}
else if (symbol == 'c')
{
System.out.println("c");
}
else
{
System.out.println("None of these");
}
}
Off the top of my head I'd think it would be something like
(define (check symbol)
(cond ((null? symbol) (display "null" ))
((equal? 'a lst) (display "a"))
((equal? 'b lst) (display "b"))
((equal? 'c lst) (display "c"))
(else (display "none of these"))
)
)
This doesn't work however and I'm pretty stuck.. any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire