2 (:use [sicp ch2_1 utils]
5 ;; the gcd version of make-rat does this automatically for us. But assuming
6 ;; we don't use gcd, here is the solution
7 (defn new-make-rat [x y]
8 (cond (and (< x 0) (< y 0)) (list (- x) (- y))
9 (or (< x 0) (< y 0)) (if (< x 0) (list x y) (list (- x) (- y)))
12 (deftest test-num-p-den-p
14 (numer (new-make-rat 2 3)) 2
15 (denom (new-make-rat 2 3)) 3))
17 (deftest test-num-p-den-n
19 (numer (new-make-rat 2 -3)) -2
20 (denom (new-make-rat 2 -3)) 3))
22 (deftest test-num-n-den-n
24 (numer (new-make-rat -2 -3)) 2
25 (denom (new-make-rat -2 -3)) 3))
27 (deftest test-num-n-den-p
29 (numer (new-make-rat -2 3)) -2
30 (denom (new-make-rat -2 3)) 3))