8.5

#### Lecture 17: Local definitions

This assignment is due on Sunday, March 6 at 11:59pm. Submit it using Handin as assignment lecture17.

##### 1Hacking the cis-tem

Watch the following video from 11m50s to 24m00s. (The automatically generated captions might help.)

“anyways, it’s always absurd when computer folk yearn for a space to do technical work ‘without politics.’

my sweet summer child, you studied a tool that inherently amplifies force. you have unlocked hard mode”

Exercise 1. Read Hacking the cis-tem: transgender citizens and the early digital state by Hicks. Focus on how different computations described by Hicks enforces different social norms.
• When you follow the link above with your browser, you should see Hicks’s article, 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.

• Find one place in the article where Hicks describes a computation.

A computation is a process whose inputs and outputs are clearly defined, like with steps 1–3 of the design recipe. A computation might also have methods and formulas that are precisely specified, like with steps 4–5 of the design recipe. Remember that computations are different from computers: calculating grades, recording names, and searching for photos are all computations, whether performed by humans, computers, or both.

Carefully select the relevant phrase, and Annotate it like this: “Here Hicks describes this computation: British spies search the Internet for photos of pensioners.”

• Find one place in the article where Hicks describes a social norm.

A social norm is something in society that usually happens, or people think it usually happens, or people think it should usually happen.

Carefully select the relevant phrase, and Annotate it like this: “Here Hicks describes this social norm: People eat with their right hand only.”

• Don’t bullshit.

##### 2Local definitions

Exercise 2. Design at least one of the following two functions.
• Design a function between-20-50 that takes a list of numbers as input and returns the list of all the given numbers between 20 and 50. The built-in function <= will help.

• Design a function all-contains-lorem that takes a list of strings as input and returns the list of all the given strings containing "lorem". The built-in function string-contains? will help.

Don’t forget that the first step of the design recipe is data definitions. The data definitions will guide you to write the examples and the templates.

Exercise 3. Here are two useful functions:
 (define-struct none []) ; A MaybePosn is one of: ; - (make-none) ; - Posn ; move-bullet : MaybePosn -> MaybePosn ; update the bullet as time passes (check-expect (move-bullet (make-none)) (make-none)) (check-expect (move-bullet (make-posn 70 50)) (make-posn 70 45)) (define (move-bullet b) (cond [(none? b) b] [(posn? b) (make-posn (posn-x b) (- (posn-y b) 5))])) ; A MaybeNumber is one of: ; - (make-none) ; - Number ; move-rocket : MaybeNumber -> MaybeNumber ; move the rocket up if it is flying (check-expect (move-rocket (make-none)) (make-none)) (check-expect (move-rocket 123) 122) (define (move-rocket r) (cond [(none? r) (make-none)] [else (- r 1)]))
Abstract from the data definitions MaybePosn and MaybeNumber to form a new data definition [Maybe X]. After you define Maybe, don’t forget to redefine MaybePosn and MaybeNumber using Maybe.

You don’t need to abstract from any functions, but when you are done, the signatures of move-bullet and move-rocket may as well be written as follows:
 ; move-bullet : [Maybe Posn] -> [Maybe Posn] ; move-rocket : [Maybe Number] -> [Maybe Number]

Exercise 4. Design another function that takes one input and returns a Boolean. If you were to give this function to select as the predicate, what would X be? Put your answer in your submission as a comment in the following format:
 ; Exercise 4 ; If I were to give the function ??? to select as the predicate, ; X would be ???