Writing negative numbers in a racket
1 answer
The negative character is part of the number itself, you write it just like you would in any other language:
(define (math x)
( = ( - ( / -12 x) 2) 4))
Output:
> (math 2) ; 2-(-12/2) = -4 -> 2-(-6) = -4 -> 2 + 6 = -4 -> 8 = -4 (FALSE)
#f
> (math -2) ; 2-(-12/-2) = -4 -> 2-(6) = -4 -> -4 = -4 (TRUE)
#t
+4
source to share