Lecture 8: Structures
This assignment is due on Tuesday, February 1 at 11:59pm. Submit it using Handin as assignment lecture8.
Remember to follow the design recipe whenever you design or write a function. In particular, every type mentioned in a signature must be introduced by a data definition, except for these well-known types: Number, Image, String, Color, Boolean.
1 Limitations of artificial intelligence
When you follow the link above with your browser, you should see Gebru’s talk, as well as a button “<” in the upper-right corner. Use the “<” button to expand the annotation sidebar.
You may need to log in to Hypothesis, using the account you created in Lecture 5: The table method.
Expand the drop-down menu “Public” in the sidebar, and change it to our course group “211”. You belong to this group because you used the invite link in Lecture 5: The table method. If you don’t post to this group, then other students won’t see your annotations, and you won’t get credit.
Use the “>” button to collapse the annotation sidebar, then watch the video. The video is synchronized with the automatic and imperfect transcript to the left.
- Find one place in Gebru’s talk where she questions or disagrees with something that people commonly believe, say, or do. Select the relevant passage in the transcript, and Annotate it like this:
“Here Gebru questions the common belief that…” or
“Here Gebru disagrees with the common statement that…” or
“Here Gebru cautions against the common practice of…”.
For example, you might add the annotation “Here Gebru disagrees with the common belief that law enforcement should use every tool available” at an appropriate place. - Once you have added your annotation, respond to an existing annotation like this:
“She does so by describing…” or
“She does so by citing…” or
“She does so by arguing that…”.
For example, you might add a response like “She does so by citing a study about…” to an appropriate existing annotation. Don’t bullshit.
2 Defining structures
; A Point is (make-point Number Number) (define-struct point [x y]) (define here (make-point 30 50)) (define there (make-point 70 45)) ; A Person is (make-person String Number) (define-struct person [name age]) (define me (make-person "Alice" 37)) (define you (make-person "Bob" 22))
; Exercise 2 ; (point-x there) ; = (point-x (make-point 70 45)) ; = ??? ; (point-y here) ; = ??? ; = ... ; (person-name you) ; = ??? ; = ... ; (point-x me) ; = ??? ; = ... ; (make-person "Carol" 21) ; = ???
make-point point-x point-y point?
Exercise 4. What are the four courtesy functions for the person structure we defined above? Write down their signatures.
; (person? me) ; = ??? ; = ... ; (person? "Alice") ; = ??? ; (person? there) ; = ???
; (- (point-x there) (point-x here)) ; = ??? ; = ... ; (< (person-age me) (person-age you)) ; = ??? ; = ... ; (point-x (point-x there)) ; = ??? ; = ... ; (person-age (make-person "Carol" 21)) ; = ??? ; (make-person (person-name me) (+ 1 (person-age me))) ; = ???
3 Designing functions using structures
; 1. Data Definitions ; A Person is (make-person String Number) (define-struct person [name age]) ; A Boolean is one of: ; - true ; - false ; 2. Signature, Purpose, Header ; teenager? : Person -> Boolean ; is a given person 13-19 years old? (define (teenager? p) ...) ; 3. Examples ; 4. Template ; 5. Definition ; 6. Tests
Optional: Read Chapter 5 of the textbook.