## Practice: Functions on Atomic Data

## by Matthias Felleisen

If you aren't quite sure about functions and atomic data or you just want to practice, design the following functions:"Design" means you do follow the design recipe.

`sales-tax`

, which consumes a price (number) and computes the MA sales tax.`total`

, which consumes a price (number) and computes what the item really costs once the sales tax is added`distance`

, which computes how far a car has driven from the given number of hours. Originally the car was 10 miles from downtown Boston; it drives at 55 miles per hour, on a straight line away from Boston.`dist`

, which adds the squares of the given two numbers and takes the root.`ave`

, which computes the average of three numbers.`good-width`

, which determines whether a given string is longer than (or equal) to some give number.`ekwal?`

, which determines whether a given string is equal to some give symbol.`mensch`

, which determines how many of two given Booleans are true; hints: this requires`cond`

and you should definitely twice about copying and modifying code.`yes/no->boolean`

, which consumes "yes" and "no" answers (probably via an interaction with a person) and translates those into appropriate Booleans.`boolean->yes/no`

, which consumes a Boolean and translate it into "yes" or "no" answers.You should be able to design those functions in 30 minutes. If you aren't, make up more exercises along those lines and practice. These kind of things must be at your finger tips by now. If you need such exercises and you can't make them, see the TAs during their office hours and ask them for suggestions.