;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname posn) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ; A posn is ; (make-posn num num) ; pixels-from-corner : posn -> num ; To compute the x offset plus the y offset ;(define (pixels-from-corner p) ; ... (posn-x p) ... (posn-y p) ...) (define (pixels-from-corner p) (+ (posn-x p) (posn-y p))) (check-expect (pixels-from-corner (make-posn 3 4)) 7) (check-expect (pixels-from-corner (make-posn 10 3)) 13) ; flip-posn : posn -> posn ; To produce a posn with p's x and y, ; but flipped ;(define (flip-posn p) ; ... (posn-x p) ... (posn-y p) ....) (define (flip-posn p) (make-posn (posn-y p) (posn-x p))) (check-expect (flip-posn (make-posn 3 4)) (make-posn 4 3)) (check-expect (flip-posn (make-posn -3 41)) (make-posn 41 -3))