odd? should check absolute value of remainder

This commit is contained in:
Alex Shinn 2012-11-01 20:33:37 +09:00
parent c0fc89ece4
commit e53230c439

View file

@ -1040,7 +1040,7 @@
(define (positive? x) (> x 0)) (define (positive? x) (> x 0))
(define (negative? x) (< x 0)) (define (negative? x) (< x 0))
(define (even? n) (= (remainder n 2) 0)) (define (even? n) (= (remainder n 2) 0))
(define (odd? n) (= (remainder n 2) 1)) (define (odd? n) (= (abs (remainder n 2)) 1))
(define (abs x) (if (< x 0) (- x) x)) (define (abs x) (if (< x 0) (- x) x))