HtDP Problem Set
Develop the function describe-temp, which consumes a Celsius temperature and returns 'Warm if the temperature is 25 or greater, 'Mild if the temperature is between 10 and 25, and 'Cold if the temperature is below 10.
Develop a function that when given a symbol and number returns the square root of the number if the symbol is 'squareroot or the tangent of the number if the symbol is 'tangent. For all other symbols, it returns the original number.
Modify check-guess from Exercise 5.1.2 (duplicated below) to add a fourth response, 'WithinTen, which is returned when the player's guess is in the range of ten above or below the target.
Develop the function check-guess. It consumes two numbers, guess and target. Depending on how guess relates to target, the function produces one of the following three answers: 'TooSmall, 'Perfect, or 'TooLarge.
The function implements one part of a two-player number guessing game. One player picks a random number between 0 and 99999. The other player's goal is to determine this number, called target, with the least number of guesses. To each guess, the first player responds with one of the three responses that check-guess implements.
The function check-guess and the teachpack guess.ss implement the first player. The teachpack picks the random number, pops up a window in which the second player can choose digits, and hands over the guess and the target to check-guess. To play the game, set the teachpack to guess.ss using the
Language|Set teachpackoption. Then evaluate the expression(guess-with-gui check-guess)after check-guess has been thoroughly tested.
Inhabitants of the island of knaves always walk around in pairs. Each will respond with 'Yes or 'No individually when asked an appropriate question. You can only be certain of having received an affirmative answer if both reply 'Yes. All other combinations imply 'No.
Develop the function discern, which will accept all pairwise combinations of knaves' answers and produce 'Yes or 'No accordingly.
A robot car is confined to a narrow straight track that is marked with positions 0 through 99.
Develop the function move. It consumes a command (either 'Forward or 'Backward), the number of units to move, and the current position of the robot, then returns the new position of the robot. The robot cannot go off the end of the track, so once it has reached either end it will remain there.
|Jamie Raymond||Matthias Felleisen|
01 december 2003