________ _______ __ __ _______ ___
/ ____/ |/ / __ \/ / / / < / __ < / Spring 2019 Section 54
/ / / /|_/ / /_/ / / / /_____/ / / / / /
/ /___/ / / / ____/ /_/ /_____/ / /_/ / / Assignment 08
\____/_/ /_/_/ \____/ /_/\____/_/ Thursday, 11th April, 2019
ASSIGNMENT IS DUE AT THE BEGINNING OF THE NEXT CLASS.
=====================================================================================
Before you begin, press CTRL+ALT+T. This will bring up a terminal window, which is
a quick way to access your network directory. Once it's open, type:
mkdir asmts
cd asmts
mkdir asmt8
cd asmt8
When you save your work today (which you should do often), you should make sure that
you save it in the asmts/asmt8 directory. THIS IS IMPORTANT!
-------------------------------------------------------------------------------------
Please provide AT LEAST THREE examples of your function running.
Don't forget to use ASMT-HELPER.TXT.
Don't forget to use the PROBLEM function before each of your solutions.
------------------------------------------------------------------------------------
Problems may be found in the Problems document on the course website.
Remember to provide contracts for your functions even when they are in the
Problems Book.
Please use the PRINT-HW instruction to print out your homework. Full details
are on the Assignments page of the course website.
==========================================================================================
PROBLEMS HIGHLIGHTED WITH ASTERISKS ARE **COACH-FREE PROBLEMS**.
1. Do Problem 15.4 from the Problem Book.
**
2. Do Problem 15.5 from the Problem Book.
**
3. Do Problem 15.6 from the Problem Book.
4. Rewrite your solution to Question 3 so it has a single function which uses LETREC to
handle the recursive call.
Call this new function NUM-TOSSES-UNTIL-THREE-LETREC.
You *must* use LETREC in your solution.
5. Do Problem 15.11 from the Problem Book.
**
6. Write a function called MEAN which fulfills the following contract:
**
;; ===================================================================
;; MEAN
;; ===================================================================
;; Computes the mean (average) die roll for a K-sided die over
;; N rolls.
;; -------------------------------------------------------------------
;; INPUTS: N, a positive integer.
;; K, a positive integer.
;; OUTPUT: None.
;; SIDE-EFFECT: Displays the running average of the rolls so far.
;; ===================================================================
Here are some examples:
> (mean 5 6)
Round 1. Rolled 5; sum is 0 + 5 = 5. Current mean is 5.0.
Round 2. Rolled 3; sum is 5 + 3 = 8. Current mean is 4.0.
Round 3. Rolled 5; sum is 8 + 5 = 13. Current mean is 4.333333333333333.
Round 4. Rolled 3; sum is 13 + 3 = 16. Current mean is 4.0.
Round 5. Rolled 4; sum is 16 + 4 = 20. Current mean is 4.0.
Done.
> (mean 5 20)
Round 1. Rolled 7; sum is 0 + 7 = 7. Current mean is 7.0.
Round 2. Rolled 14; sum is 7 + 14 = 21. Current mean is 10.5.
Round 3. Rolled 17; sum is 21 + 17 = 38. Current mean is 12.666666666666666.
Round 4. Rolled 7; sum is 38 + 7 = 45. Current mean is 11.25.
Round 5. Rolled 15; sum is 45 + 15 = 60. Current mean is 12.0.
Done.
>
You must use LETREC to get full credit for this problem.
You must not write a separate wrapper function to get full credit for this problem.
HINT: You may find it useful (or necessary) to use a nested LET or LET*.
------------------------------------------------------------------------------------------
Don't forget to submit your work using the SUBMIT101 command!
submit101 e-asmt8 asmt8
(If the name of your directory is different from 'asmt8', change 'asmt8' to whatever
the name of your directory is.)
==========================================================================================
==========================================================================================