Due Date Thursday 05/07 at 10pm EST
Purpose To write simple functions.
For this assignment and all future assignments you must upload one .rkt file in the language specified at the top of the assignment to the Handin Server. Failure to do so will result in a 0. No exceptions.
Exercise 1 Exercises 1-4 in HtDP
Exercise 2 Copy the following expression into your file and provide a single-line comment, translating the code into English.
- Copy the following function into your .rkt file and give it a signature:
Confirm this signature by either defining constants or writing a check-expect that passes. If you choose the path of constants you must define ACTUAL-OUTPUT to be the result of calling blarney on your choice of inputs and you must define EXPECTED-OUTPUT to be the result you expect to be produced by ACTUAL-OUTPUT. You should run your code to ensure that these two constants have the same value. As this code is nonsense, do not provide a purpose statement. For functions with which you aren’t familiar, refer to the DrRacket documentation.
Exercise 4 Take a look at the figure below, which is a graph of f, a function of x.
Turn the graph into a table for x = 0, 1, 2 and 3. The table can be very simple and should be commented out in your .rkt file.
Formulate a BSL function definition for f.
Exercise 5 Define the function self-replicate which replicates a string n times, where n is the length of the string. You will find the replicate function useful. Be sure to provide a signature, purpose statement, and either constants or check-expect statements to demonstrate that the function works as expected for several examples (including the empty string, "").