[archives] [homepage]

Problem 2.1
Friday, August 23, 2019; ago; Download .md

SICP Exercise 2.1

(define (make-rat n d)
  (cond ((and (< n 0) (< d 0))
         (let ((g (gcd (* -1 n) (* -1 d))))
           (cons (/ n g) (/ d g))))
        ((< d 0)
         (let ((g (gcd (* -1 n) (* -1 d))))
           (cons (/ n g) (/ d g))))
        (else
        	(let ((g (gcd n d))
           	 (cons (/ n g) (/ d g))))))