Writing negative numbers in a racket
2 - (-12 / x) = -4
negative 12 is what confuses me. where to put the negative sign?
(define (math x)
( = ( - ( / 12 x) 2) 4))
+3
Josh
source
to share
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
Hunter mcmillen
source
to share