;; a coordinate is a structure ;; (make-coord num num) (define-struct coord (x y)) ;; Examples of coords (make-coord 0 8) (make-coord -1 4)
;; move-coord-vertical : coord number -> coord ;; consumes a coordinate and a number by which to move the coordinate in the ;; vertical position and produces a coordinate in the new position. (define (move-coord-vertical a-coord delta) (make-coord (coord-x a-coord) (+ (coord-y a-coord) delta))) ;; Test cases (move-coord-vertical (make-coord 0 8) 5) ;; expect (make-coord 0 13) (move-coord-vertical (make-coord 4 -2) 7) ;; expect (make-coord 4 5) (move-coord-vertical (make-coord -1 4) -4) ;; expect (make-coord -1 0)
This page maintained by Mike Gennert Department of Computer Science Worcester Polytechnic Institute |