8.12

### Lecture 14: Built-in structuresðŸ”—

This assignment is due on Tuesday, February 20 at 11:59pm. Submit it using Handin as assignment lecture14.

#### 1Built-in structuresðŸ”—

Rebecca Heineman is a game developer, hacker, and author who won the first e-sports championship in 1980. You can watch the game Space Invaders being played, or even play it yourself (use the arrow keys to move, and Alt or Option to fire).

Exercise 1. Define 3 examples of ListOfInvaders that did not appear in the video above. Then, explain in a comment why
 (cons (make-posn 12 34) (make-posn 56 78))

Exercise 2. Calculate step-by-step:
 (posn-y (first (rest (cons (make-posn 12 34) (cons (make-posn 56 78) empty))))) ; = ???

Exercise 3. Write the data definition for a ListOfNumbers. Then, define 2 non-empty examples of ListOfNumbers. Why is (cons 1234 5678) not a ListOfNumbers?

 (require 2htdp/image) (define background (rectangle 200 300 "solid" "black")) ; A Posn is (make-posn Number Number) ; A ListOfPosns is one of: ; - empty ; - (cons Posn ListOfPosns)
Finish designing at least one of the following two functions. You’ll need to write more examples. (Feel free to design a helper function to process each Posn. Also feel free to define constants to make your examples and definitions clearer and shorter.)
 ; draw-invaders : ListOfPosns -> Image ; draws invader markers at the given positions ; (define (draw-invaders ps) ...) (check-expect (draw-invaders empty) background) ; move-invaders : ListOfPosns -> ListOfPosns ; increase each Y coordinate by 1 ; (define (move-invaders ps) ...) (check-expect (move-invaders empty) empty)

Exercise 5. Examine the data definition of NaturalNumber in the video above. How many cases does it have? Then examine the template for processing a NaturalNumber in the video above. How many cases does it have? What do these numbers have in common? Why should they?