Assignment 2a
Due Date Tues 9/12 at 9:00pm
Possible Points 1
Purpose To practice submitting a file and writing some basic functions.
For this assignment and all future assignments you must upload a .rkt file in the specified language at the top of the assignment. Failure to do so will result in a 0. No exceptions. This will also be the last individual assignment of the semester. Future assignments will be submitted with lab partners (to be assigned on Tuesday, 9/12, in lab).
Finger Exercises You are not required to submit your finger exercises but they will be helpful so we recommend doing them anyway.
Exercise 1 Write a function that subtracts 2 from a number.
Exercise 2 The following table describes how far a person has gone in a race in a certain amount of seconds:
t =
1
2
3
4
5
6
7
8
9
10
d =
3
4.5
6.0
7.5
9.0
10.5
12.0
13.5
?
?
Write a function that predicts, based on this data, how far they will have run at time t. Write three check-expects: two that test to see the data in the table matches your function’s output, and then one more that tests the output when t is at least 9.
Exercise 3 Take a look at figure 1, which is a graph of f, a function of x.
Turn the graph into a table for x = 0, 1, 2 and 3 and formulate a function definition.
Graded Exercises
Exercise 4 Complete the following table:
t =
1
2
3
4
5
6
d =
QWERT
QWER
QWE
QW
?
?
Turn this table into a function definition. The function takes natural numbers and produces strings. A natural number is 0, 1, 2, 3, 4, 5, etc.
Exercise 5 Develop the function qwerty. The function consumes a natural number and extracts that many keyboard characters from the string "qwerty".
What happens when the function is applied to 13? In that case, qwerty produces just the string "qwerty". The same happens for all other numbers that are too large.