【SICP练习】43 练习2.2

简介:


练习2.2

(define(make-segment start-point end-point)

(cons start-point end-point))

(define(start-segment seg)

(car seg))

(define(start-segment seg)

     (cdr seg))

(define(make-point x y)

       (cons x y))

(define(x-point p)

(car p))

(define(y-point p)

(cdr p))

(define(average x y)

     (/ (+ x y) 2.0))

(define(mid-segment seg)

       (let ((start (start-segment seg))

         (end (end-segment seg)))

       (make-point (average (x-point start)(x-point end))

                    (average (y-point start)(y-point end)))))

(define(print-point p)

   (newline)

   (display “(“)

   (display (x-point p))

   (display “,”)

   (display (y-point p))

   (display “)”))

目录
相关文章
|
Go
【SICP练习】146 练习4.2
版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/44729521 练习4-2 原文 Exercise 4.
671 0
|
数据安全/隐私保护
下一篇
无影云桌面