Due: Friday, August 25th, 2017 11:59pm
After installing the uu-cs5510 package as described in the course web page, select the Manage CS 5510 Handin... menu item from DrRacket’s File menu. Change to the New User panel, and pick a username and password. (Use your real name and real Utah student ID, so that we can connect your homework submissions with you.)
You will have to install uu-cs5510 for DrRacket on each different filesystem that you use to get a Handin button. However, after creating a handin account once from any machine, you can use DrRacket’s Handin button on any other machine.
Use #lang plai-typed at the start of your program, so that it’s implemented in the plai-typed language.
Define the function 3rd-power, which takes a number and raises it to the 3rd power.
Your program should include test forms to check 3rd-power on a few inputs.
Example use: (3rd-power 17) should produce 4913.
Define the function 42nd-power (in the same program), which takes a number and raises it to the 42nd power.
It’s probably a good idea to use functions like 3rd-power to build up to 42nd-power.
Your program should include test forms to check 42nd-power on a few inputs.
Example use: (42nd-power 17) should produce 4773695331839566234818968439734627784374274207965089.
Define plural, which takes a string and returns a string. If the given string ends in “y”, the the result should be the same as the input but with the “y” replaced by “ies”. Otherwise, the result should be the same as the given string with “s” added to the end.
Your program should include test forms to check plural on a few inputs.
Example uses: (plural "baby") should produce "babies", while (plural "fish") should produce "fishs".
Use the following type definition (add it to your program):
(define-type Light [bulb (watts : number) (technology : symbol)] [candle (inches : number)])
Implement the function enery-usage, which takes a Light and produces the number of kilowatthours of electricity that the light uses in 24 hours. Your function will need to use (type-case Light ....).
As always, include relevant test forms.
Example uses: (energy-usage (bulb 100.0 'halogen)) should produce 2.4, while (energy-usage (candle 10.0)) should produce 0.0 or 0.
Implement the function use-for-one-hour, which takes a Light and produces another Light that represents the given light source after it is used for another hour. Assume that a candle burns one inch per hour (unless it is already gone), and assume that a lightbulb is the same after one hour of use.
Example uses: (use-for-one-hour (bulb 100.0 'halogen)) should produce (bulb 100.0 'halogen), while (use-for-one-hour (candle 10.0)) should produce (candle 9.0).
Click the Handin button in DrRacket to submit your homework. The Handin button submits whatever is in DrRacket’s definitions area, so click Handin after you ave defined 3rd-power, 42nd-power, plural, energy-usage, and use-for-one-hour, all in the same program. The submission process will check that you have defined the right names.
|Last update: Sunday, August 20th, firstname.lastname@example.org|