In farming and gardening, it is sometimes desirable to add or restore nutrients to the soil by adding not only humus (decaying plant matter) but also some kind of fertilizer. Chemical fertilizers promote growth, but they are highly concentrated, and applying the wrong dose or failing to spread it out evenly enough can cause actual damage to the roots of plants, kill beneficial microorganisms in the soil, and drive away earthworms that aerate and mix the soil. For this reason, many gardeners prefer to use organic fertilizers made from bone meal, old coffee grounds, wood ashes, and so on.
Because a single organic material does not necessarily provide nutrients in the correct relative proportions, it is usual to mix them together -- combining, for instance, bone meal (which is high in phosphorus), cottonseed meal (high in nitrogen), and wood ashes (high in potassium) in appropriate amounts. The program that you'll be looking at today allows the user to compute the percentage (by weight) of various nutrients in any specified mixture of materials commonly used in organic fertilizers.
Unfortunately, clicking on the Run button reveals that this program
doesn't work:
> (nitrogen-percentage high-nitrogen-mix) (bug) car: expects argument of type <pair>; given blood-meal
Find and correct the error(s) in the program.
Extend the program by writing a procedure that takes two arguments -- a recipe for a particular mix of fertilizer and the weight (in kilograms) of the amount of fertilizer to be made up from that recipe -- and computes and returns the weight (in kilograms) of each of the organic materials in the recipe.
I am indebted to Professor Ben Gum for his contributions to the development of this lab.