Blame


1 665c255d 2023-08-04 jrmu (defun make-rat (n d)
2 665c255d 2023-08-04 jrmu (labels ((make-rat-reduce (n d)
3 665c255d 2023-08-04 jrmu (let ((g (gcd n d)))
4 665c255d 2023-08-04 jrmu (cons (/ n g) (/ d g)))))
5 665c255d 2023-08-04 jrmu (cond ((and (< n 0) (< d 0))
6 665c255d 2023-08-04 jrmu (make-rat-reduce (- n) (- d)))
7 665c255d 2023-08-04 jrmu ((and (< d 0) (> n 0))
8 665c255d 2023-08-04 jrmu (make-rat-reduce (- n) (- d)))
9 665c255d 2023-08-04 jrmu (t (make-rat-reduce n d)))))
10 665c255d 2023-08-04 jrmu (defun numer (x)
11 665c255d 2023-08-04 jrmu (car x))
12 665c255d 2023-08-04 jrmu (defun denom (x)
13 665c255d 2023-08-04 jrmu (cdr x))
14 665c255d 2023-08-04 jrmu