练习2.1

版权声明:本文为博主原创文章,转载请注明出处,谢谢!

版权声明:本文为博主原创文章,转载请注明出处:http://blog.jerkybible.com/2014/01/14/2014-01-14-练习2.1/

访问原文「练习2.1

1.练习2.1

1
2
3
4
5
6
7
8
9
10
11
12
(define (check-pos-neg a b)
(or (and (not (< a 0)) (> b 0))
(and (not (> a 0)) (< b 0))))
(define (make-rat n d)
(let ((g (gcd (abs n) (abs d)))
(posi (check-pos-neg n d)))
(cons (/ (if posi
(abs n)
(- (abs n)))
g)
(/ (abs d) g))))
Jerky Lu wechat
欢迎加入微信公众号