;;;; ;;;; Step 2 - Point Abstraction: Starting a 2-Dimensional Point System ;;;; ;; make-point (define (make-point x y) (cons x y)) ;; get-x (define (get-x p) (car p)) ;; get-y (define (get-y p) (cdr p)) ;; Test Code Instructions: ;; Define a new point. Display it. ;; Display the x and y values separately using your selectors. ;; You may use this point in future tests as well. ;; Note: ;; The above is done for you below -- just uncomment those lines. ;; You may want to define some other points here to use in future steps. (display+ "--- STEP 2 TEST CASES ---") ;; Example Test Case: (define pt1 (make-point 2 4)) (define pt2 (make-point 4 6)) (define pt3 (make-point 1 9)) (define pt4 (make-point 5 7)) (display+ "Point: "pt1) ;; Expecting (2 . 4) (display+ "X-Coord: " (get-x pt1)) ;; Expecting 2 (display+ "Y-Coord: " (get-y pt1)) ;; Expecting 4 ;;;; ;;;; Step 3 - Maintaining a List of Points ;;;; ;; make-pt-list (define (make-pt-list p pt-list) (cons p pt-list)) ;; the-empty-pt-list (define the-empty-pt-list ()) ;; get-first-point (define (get-first-point pt-list) (car pt-list)) ;; get-rest-points (define (get-rest-points pt-list) (cdr pt-list)) ;; Test Code: ;; Using make-pt-list and the-empty-pt-list, define a list with 6+ points. ;; Show the list after each point is added. ;; Display the entire list, the first point, and all but the first point. ;; Display the second point. ;; Display all except the first two points. (display+ "--- STEP 3 - Building The List ---") ;; How to start building the list: ;; (define my-point-list (make-pt-list pt1 the-empty-pt-list)) ;; (display+ my-point-list) ;; ;; (define my-point-list (make-pt-list pt2 my-point-list)) ;; (display+ my-point-list) ;; ;; Continue adding points... (display+ "--- STEP 3 - First Point ---") (define my-pt-list (make-pt-list pt1 the-empty-pt-list)) (display+ my-pt-list) (define my-pt-list (make-pt-list pt2 my-pt-list)) (display+ my-pt-list) (define my-pt-list (make-pt-list pt3 my-pt-list)) (display+ my-pt-list) (define my-pt-list (make-pt-list pt4 my-pt-list)) (display+ my-pt-list) (define my-pt-list (make-pt-list pt3 my-pt-list)) (display+ my-pt-list) (define my-pt-list (make-pt-list pt2 my-pt-list)) (display+ my-pt-list) (display+ (get-first-point my-pt-list)) (display+ (get-rest-points my-pt-list)) (display+ "--- STEP 3 - Second Point ---") (display+ (get-first-point (get-rest-points my-pt-list))) (display+ "--- STEP 3 - All Except First Two Points ---") (display+ (get-rest-points (get-rest-points my-pt-list)))