temporary

temporary - ;; posn-x and posn-y also come as well with the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
;; The first three lines of this file were inserted by DrScheme. 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 temporary) (read-case- sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; Ru Wang 20319247 CS135 001 Tut 108 ; ;; Question 3: ; ;; Part a: ;; Data Definition: (define-struct line ( point slope)) ;; Analysis: Functions that come along with the structure: ;; constructor: make-line: consumes a posn and a number or 'vertical symbol to make a line ;; selector: line-point: returns the point for the line in posn.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ;; posn-x and posn-y also come as well with the structure posn. ;; selector: line-slope: returns a slope in number or the symbol 'vertical when slope is vertical (infinite) s ;; part b: ;; points->line: posn posn -> line ;; purpose: to consume 2 points and generate a line out of them ;; Template: ;; (define (points->line point1 point2) ;; ...(x-posn point1). .. ;; ...(y-posn point1). .. ;; ...(x-posn point2). .. ;; ...(y-posn point2). ..) ;; Examples: (points->line (make-posn 1 1) (make-posn 1 1)) => error: 2 points given are the same ;; (points->line (make-posn 1 1) (make-posn 2 2)) => (make-line (make-posn 1 1) p (define (points->line posn1 posn2) (...
View Full Document

Ask a homework question - tutors are online