<< Previous exercise (2.45) | Index | Next exercise (2.47) >>
saving a few lines of code
(define (f-vect v1 v2 f) (cons (f (xcor-vect v1) (xcor-vect v2)) (f (ycor-vect v1) (ycor-vect v2)))) (define (add-vect v1 v2) (f-vect v1 v2 +)) (define (sub-vect v1 v2) (f-vect v1 v2 -))
I defined some simple tests to make sure that everything works. Obviously total overkill for the problem at hand, but I wanted to try setting up simple tests in this language like I do for all other languages I use.