I have a problem with this example
(define (+ x y)
(if (= x 0)
y
(+ (-1+ x) (1+ y))))
What is the problem with -1+ and 1+, when i evaluate it i get this result
but i write this instead and it works
(define (add x y)
(if (= x 0)
y
(+ (- x 1) (+ y 1))))
For Racket:
add1
instead of 1+
sub1
instead of -1+
or 1-
The trouble is, none of those names are standard, so you can't reliably use them across all Scheme implementations. :-)
You can fix this by adding SICP support to DrRacket.
http://www.neilvandyke.org/racket-sicp/
Anymore trouble let me know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With