Name | Role | Office | Office hours | |
---|---|---|---|---|
Svetlozar Nestorov | Instructor | Ryerson 275-A | by appt. | evtimov at cs.uchicago.edu |
Varsha Dani | TA | Ryerson 162A | - | varsha at cs.uchicago.edu |
Casey Klein | TA | Ryerson 178 | Tu 1:30-2:30pm | clklein at cs.uchicago.edu |
Jing Tie | TA | RI 340 | Fr 3-4pm | jtie at cs.uchicago.edu |
Week | Topic | Readings |
1 | Basic forms of data | Ch 2 - 6 |
2 | define-struct, unions and lists | Ch 6 - 10 |
3 | Lists, trees, and data abstraction | Ch 12 - 16 |
4 | Iterative refinement, 2 complex pieces of data, local | Ch 16 - 18 |
5 | Mutually referential data definitions, abstraction | Ch 15, 19 - 21 |
6 | Abstraction, lambda, natural numbers | Ch 19 - 22, 24, 11 |
7 | Generative recursion, graphs | Ch 25 - 28 |
8 | Accumulators, more graphs | Ch 30 - 32, 14 |
9 | Evaluators | |
10 | Looking forward |
Due Date | Language (in DrScheme) | Problems |
---|---|---|
9/28 | Beginning Student | Images: 1.1 - 1.5 |
10/1 | Beginning Student | Images: 2.1 - 2.3, 3.1 - 3.2 |
10/3 | Beginning Student |
Write the function direct-to-0 : posn -> number that
determines how far a posn is from the origin.
Write the function downtown-to-0 : posn -> number that determines how far a posn is from the origin, if the coordinates were block numbers. That is, you cannot cut through buildings and have to walk on streets (this is commonly called "Manhattan" distance). Write the function direct-between : posn posn -> number that determines the distance between two points. (Hint: wishlists & reuse!) HtDP: 7.2.2 (make sure all vehicles have wheels) Develop the function toll : vehicle -> number. It determines the amount a vehicle must pay at a toll. The toll costs $0.50 per wheel. Extend the animal data definition from class with one new kind of animal. Make sure the new animal has a weight. Write the function diet : animal -> animal. It accepts an animal and returns the same animal, but with half of the weight. |
10/8 | Beginning Student | Write the following functions. Don't forget about
re-use and helper functions (the functions we wrote in class are fair
game for re-use as helper functions). ; a list-of-symbols is either ; - empty, or ; - (cons symbol list-of-symbols) ; contains-doll? : list-of-symbols -> boolean ; to determine if 'doll appears in alos (define (contains-doll? alos) ...) ; a list-of-numbers is either ; - empty, or ; - (cons number list-of-numbers) ; len : list-of-numbers -> number ; to determine the number of elements in alon (define (len alon) ...) ; avg : list-of-numbers -> number ; to determine the average of the elements in alon (define (avg alon) ...) ; sq-nums : list-of-numbers -> list-of-numbers ; to square each element in alon (define (sq-nums alon) ...) ; rev : list-of-numbers -> list-of-numbers ; to reverse the elements in alon (define (rev alon) ...) Images: 4.1 - 4.3 Hint: break down complex tasks into smaller ones. Wishlists! |
10/10 | Beginning Student w/List Abbreviations | Develop the function bm. The function
consumes two numbers (n and m) and a symbol (s). It produces a list of
n lists. Each of these lists is a list of m symbols, namely, s.
Hint: You need an auxiliary function. Consider the following modification. Instead of using the same symbol over and over again, create a string that says "cell23" where 2 and 3 are (running) indices. You can us the functions string-append which concatenates two strings and number->string which creates a string representation from a number. This variant is, for example, useful in Web programming. |
10/15 | Beginning Student w/List Abbreviations | Write the following functions. ; a ftn is either ; - 'unknown, or ; - (make-child symbol number symbol ftn ftn) (define-struct child (name date eyes mom dad)) ; 40-year-old-ancestor? : ftn -> boolean ; to determine if a 40-year-old ancestor is in a-ftn (define (40-year-old-ancestor? a-ftn) ...) ; count : ftn -> number ; to count the number of people in a-ftn (define (count a-ftn) ...) ; avg-age : ftn -> number ; to determine the average age in an-ftn (define (avg-age a-ftn) ...) Hint: use helper functions ;; above : image image -> image ;; to put one image above another ;; HINT: use put-pinhole to move the pinhole of ;; the first to the middle of the bottom edge ;; and the second to the middle of the top edge (define (above i1 i2) ...) ;; a lego is ;; - (make-lego symbol number) (define-struct lego (color width)) ;; lego->image : lego -> image ;; to render a lego brick. All legos are rectangular ;; and are 10 pixels tall (define (lego->image l) ...) ;; a lego-building is either: ;; - lego ;; - (make-bigger lego lego-building lego-building) (define-struct bigger (lego left right)) ;; how-high : lego-building -> number ;; to determine how high a lego building is, in pixels ;; (reminder: each lego is ten pixels tall) (define (how-high an-lb) ...) ;; find-colored-brick : lego-building color -> lego or false ;; to find any colored brick with the color `color' in an-lb ;; or return false if there are no such legos. (define (find-colored-brick an-lb color) ...) ;; lb->image : lego-building -> image ;; to render a lego building into an image (define (lb->image an-lb) ...) ;; Examples as tests ;; (make more tests yourself -- these should be your last tests!) (lb->image (make-bigger (make-lego 'blue 100) (make-bigger (make-lego 'green 60) (make-lego 'orange 40) (make-lego 'purple 40)) (make-bigger (make-lego 'pink 60) (make-lego 'orange 40) (make-lego 'purple 40)))) ![]() (lb->image (make-bigger (make-lego 'lightblue 80) (make-bigger (make-lego 'blue 40) (make-bigger (make-lego 'green 20) (make-lego 'orange 10) (make-lego 'purple 10)) (make-bigger (make-lego 'pink 20) (make-lego 'orange 10) (make-lego 'purple 10))) (make-bigger (make-lego 'salmon 40) (make-bigger (make-lego 'green 20) (make-lego 'orange 10) (make-lego 'purple 10)) (make-bigger (make-lego 'pink 20) (make-lego 'orange 10) (make-lego 'purple 10))))) ![]() |
10/22 | Intermediate Student | HtDP: 17.1.2, 17.6.5, 18.1.5 (1,2,5) |