;; 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-advanced-reader.ss" "lang")((modname |29.3|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))))) ;norm : vector -> number ;Produces the square root of the sum of the numbers in avector. (define (norm avector) (sqrt (sum-of-squares avector 0))) ;sum-of-squares : vector N -> number ;Given avector and i, square the element in avector from [i,vector-length) and then sum them (define (sum-of-squares avector i) (cond [(= (vector-length avector) i) 0] [else (+ (sqr (vector-ref avector i)) (sum-of-squares avector (add1 i)))])) ;vector-contains-doll? : (vectorof symbols) -> boolean ;Given avector, determine if it contains 'doll. (define (vector-contains-doll? avector) (vector-contains-doll?-aux avector 0)) ;vector-contains-doll?-aux : (vectorof symbols) N -> boolean ;Given avector and i, determine if avector contains 'doll. (define (vector-contains-doll?-aux avector i) (cond [(= (vector-length avector) i) false] [else (or (symbol=? (vector-ref avector i) 'doll) (vector-contains-doll?-aux avector (add1 i)))])) (define vector2 (vector 'robot 'car 'eraser 'pen 'motorcycle 'bicycle 'helmet 'monitor 'dolly 'policeman 'diamond)) (vector-contains-doll? vector2)