【SICP练习】75 练习2.46



练习2.46

这道题就是彻头彻尾的构造了。直接上代码吧。

(define (make-vect xcor ycor) (listxcor ycor))

(define (xcor-vect v) (car v))

(define (ycor-vect v) (cdr v))

(define (add-vect first-vectsecond-vect)

  (make-vect (+ (xcor-vect first-vect)

                (xcor-vect second-vect))

             (+ (ycor-vect first-vect)

              (ycor-vect second-vect))))

(define (sub-vect first-vectsecond-vect)

  (make-vect (- (xcor-vect first-vect)

                (xcor-vect second-vect))

             (- (ycor-vect first-vect)

              (ycor-vect second-vect))))

(define (scale-vect vect factor)

  (make-vect (* (xcor-vect vect) factor)

              (* (ycor-vect vect) factor)))

版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。

posted @ 2015-02-22 14:03  nomasp  阅读(119)  评论(0编辑  收藏  举报