CPSC 110 Lecture 11: CPSC 110

120 views3 pages
Verified Note
27 Oct 2018
School
Course
Professor

Document Summary

In this problem imagine you have information about a bunch of people that you would like to store as data and present in different ways. ;; constants: (define font-size 24) (define font-colour "blue") ;; data definitions: (@htdd person) (define-struct person (name age)) [else ( (fn-for-person (first lop)) (fn-for-lop (rest lop)))])) ;; functions: (@htdf arrange-people) (@signature listofperson -> image) ;(define (arrange-people lop) empty-image) ;stub (@template fn-composition) (define (arrange-people lop) (layout-people (sort-people lop))) (@htdf layout-people) (@signature listofperson -> image) ;(define (layout-people lop) empty-image) ;stub (@template listofperson) (define (layout-people lop) (cond [(empty? lop) empty-image] [else (above (render-person (first lop)) (layout-people (rest lop)))])) (@htdf render-person) (@signature person -> image) ;; produce an image of a person (check-expect (render-person p1) (text "wendy: 14" font-size font-colour)) (check-expect (render-person p3) (text (string-append (person-name p3) (number->string (person-age p3))) ;(define (render-person p) empty-image) ;stub (@template person) (define (render-person p) (text (string-append (person-name p) ": " (number->string (person-age p)))

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers