CISC108 Lecture Notes - Lecture 9: Complex Instruction Set Computing, Animage

28 views3 pages

Document Summary

;; examples: (define lon1 empty) ;; the empty list (define lon2 (cons 3 lon1)) ;; the list: 3 (define lon3 (cons 45 lon2)) ;; the list 45, 3. ;; lon-fun : list-of-number -> (define (lon-fun lon) (cond [(empty? lon) ] ;; lon lon : any list of numbers. ;; produces: list of squares of those numbers (check-expect (square-all lon1) empty) (check-expect (square-all lon2) (cons 9 empty)) (check-expect (square-all lon3) (cons (sqr 45) (cons 9 empty))) (define (square-all lon) (cond [(empty? lon) empty] [(cons? lon) (cons (sqr (first lon)) (square-all (rest lon)))])) (require 2htdp/image) ;; examples: (define loi1 (cons (square 50 solid red) (cons (square 3 solid blue) empty))) ;; area: image -> number (define (area an-image) (* (image-height an-image) (image-width an-image))) ;; loi loi : any list of images. ;; produces: list of sizes of those images (check-expect (sizes loi1) (cons (* 50 50) (cons (* 3 3) empty))) (define (sizes loi) (cond [(empty? loi) empty]

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents