I am trying to write a simple program in Racket that prints 1 if the value of a
is > 1
, prints 0
if the value of a = 0
and -1
if a < 0
. I wrote the following but looks like it is not taking care of the third condition. Actually, I have not included the third condition so I don't know how to check for all three conditions using 'if' clause. A little guidance is appreciated.
I am new to Racket. My program is:
#lang racket
(define a 3);
(if (> a 0)
0
1)
-1
Thanks in advance.
racket
(not alsoscheme
): Although not mandatory it's idiomatic in Racket to use square brackets for certain forms like the clauses incond
. For example(cond [cond expr] [else expr])
. – Oran