Problem Set 2

home work!

Programming Language BSL

Purpose The purpose of this problem set is to practice developing simple and conditional functions. The functions deal with atomic forms of data (numbers, symbols, images).

Finger Exercises HtDP/2e: 13, 18, 19, 20, 21; 30, 31; 61, 64


Problem 1 Design favorite-star. Given the side-length of a pentagon, the color of the star, and a length sq-len, it places an appropriately sized and colored star in the middle of a square of the given length sq-len.

Problem 2 HtDP/2e: 44. You will also have to solve preceding exercises but all you need to hand in is the solution of exercise 44.

Problem 3 People consider a climate humid if the average humidity is above 65%; in contrast, when the humidity is below 20%, people say it is dry. For percentages in between those two, people find it comfortable.

Design a function that translates measured percentages of humidity into words that describe human sensations.

Problem 4 Design a program that translates a blue object closer to a red object on a 200 x 200 plane. Specifically, the main function consumes two Posns, one called red and blue. It produces an image that contains:
  1. a blue dot

  2. a red dot

  3. a black line between the blue and the red dots

  4. a green dot on this line, 10% closer to the red dot than the blue one.

Here is a sample output:


Domain Knowledge (Geometry) To find the green point between the red and the blue one, cut the "distance" in each dimension to 90% and add the results to the respective coordinates of the red point. For this "formula" to work, you need to keep in mind that the blue point is to be translated (that’s the geometric term) in the direction of the red point.

Follow the design recipe for programs.