a1q3 - -1 1)(make-posn 1 -1))) ; => (list (make-posn 0...

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-intermediate-reader.ss" "lang")((modname a1q3) (read-case- sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; CS 116 ;; r46wang Ru WAng 20319247 ;; Assignment 1 question 3 ;; first-quadrant: (listof posn) -> (listof posn) ;; purpose: to filter through the list of posns and returns a list of the posns in the first quadrant. ;; examples: ;; (first-quadrant empty) => empty ;; (first-quadrant (list (make-posn -1 -1)(make-posn -1 1)(make-posn 1 -1))) => empty ;; (first-quadrant (list (make-posn 1 1)(make-posn 2 2)(make-posn 0 0))) => (list (make-posn 1 1)(make-posn 2 2)(make-posn 0 0)) ;; (first-quadrant (list (make-posn 0 0)(make-posn -1 -1)(make-posn 1 1)(make-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: -1 1)(make-posn 1 -1))) ; => (list (make-posn 0 0) (make-posn 1 1)) ;; first-quadrant?: posn -> boolean ;; returns true if the posn is in the first quadrant. (define (first-quadrant lop) (local [(define (first-quadrant? p) (and (>= (posn-x p) 0)(>= (posn-y p) 0)))] (filter first-quadrant? lop))) ;; tests: (check-expect (first-quadrant empty) empty) (check-expect (first-quadrant (list (make-posn -1 -1)(make-posn -1 1)(make-posn 1 -1))) empty) (check-expect (first-quadrant (list (make-posn 1 1)(make-posn 2 2)(make-posn 0 0))) (list (make-posn 1 1)(make-posn 2 2)(make-posn 0 0))) (check-expect (first-quadrant (list (make-posn 0 0)(make-posn -1 -1)(make-posn 1 1) (make-posn -1 1)(make-posn 1 -1))) (list (make-posn 0 0) (make-posn 1 1)))...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 116 taught by Professor T.vasiga during the Fall '09 term at Waterloo.

Ask a homework question - tutors are online