有理数
(make-rat <n> <d>)
(numer <x>)
(denom <x>)
(print-rat <x>)
(define (+rat x y)
  (make-rat (+ (* (numer x) (denom y))
               (* (denom x) (numer y)))
            (* (denom x) (denom y))))
> (define one-half (make-rat 1 2))
> (define one-third (make-rat 1 3))
> (print-rat (+rat one-half one-third))
5/6
done


一覧 前へ 次へ