;;; fertilizer.ss -- evaluating plant nutrients in common fertilizer mixes ;;; John David Stone ;;; Department of Mathematics and Computer Science ;;; Grinnell College ;;; stone@math.grin.edu ;;; Created February 22, 1998 ;;; Last revised February 22, 1998 ;;; 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. ;;; Fertilizer is applied to supply three major plant nutrients: nitrogen, ;;; phosphorus, and potassium. The following association list gives a ;;; number of materials that are commonly used in organic fertilizers and ;;; the percentage of nitrogen, phosphorus, and potassium in each (by ;;; weight): (define composition ;; material nitrogen phosphorus potassium '((blood-meal 15.0 1.3 0.7) (bone-meal 4.0 21.0 0.2) (cocoa-shell-meal 2.5 1.5 2.5) (composted-horse-manure 0.7 0.3 0.6) (composted-leaf-mold 0.6 0.2 0.4) (corn-stalks 0.8 0.4 0.9) (cottonseed-meal 7.0 2.5 1.5) (dried-blood 13.5 3.0 0.0) (dried-cattle-manure 2.0 1.8 2.2) (dried-coffee-grounds 2.0 0.4 0.7) (fish-emulsion 5.0 2.0 2.0) (fresh-cattle-manure 0.3 0.2 0.4) (fresh-horse-manure 0.4 0.2 0.4) (greensand 0.0 1.5 5.0) (maple-leaves 0.5 0.1 0.5) (oak-leaves 0.8 0.4 0.2) (rock-phosphate 0.0 39.0 4.5) (seaweed 1.7 0.8 5.0) (soybean-meal 6.0 1.2 1.5) (wood-ashes 0.0 1.5 7.0))) ;;; This table is taken, with minor changes, from _Square Foot Gardening_, ;;; by Mel Bartholomew (Emmaus, Pennsylvania: Rodale Press, 1981), page 61. ;;; Since this table is an association list in which the keys are symbols, ;;; we can use the built-in ASSQ procedure to look up any of the entries in ;;; it. For instance, the procedure call (ASSQ 'FISH-EMULSION COMPOSITION) ;;; will yield the list (FISH-EMULSION 5.0 2.0 2.0). The following ;;; procedures are used to pick out the numerical values for the various ;;; nutrients from the list that ASSQ returns: (define nitrogen-part cadr) (define phosphorus-part caddr) (define potassium-part cadddr) ;;; Bartholomew gives two examples of how the materials listed above can be ;;; usefully combined: ;;; (1) His ``basic all-purpose fertilizer'' consists of one part of blood ;;; meal, two parts of bone meal, three parts of wood ashes and four parts ;;; of composted leaf mold. The ``parts'' are simply equal-weight amounts; ;;; for instance, to mix ten kilograms of fertilizer using this recipe, one ;;; would make each part equal to one kilogram. ;;; (2) Bartholomew's ``high-nitrogen mix'' consists of three parts of ;;; blood meal, two of bone meal, three of wood ashes and four of composted ;;; leaf mold. You use this to promote rapid growth in leafy green ;;; vegetables, such as lettuce and Swiss chard. ;;; We can represent a fertilizer mix as a list of pairs, with the car of ;;; each pair giving one of the component materials and the cdr giving the ;;; number of parts of that material to be included: (define basic-all-purpose-fertilizer '((blood-meal . 1) (bone-meal . 2) (wood-ashes . 3) (composted-leaf-mold . 4))) (define high-nitrogen-mix '((blood-meal . 3) (bone-meal . 2) (wood-ashes . 3) (composted-leaf-mold . 4))) ;;; The following definitions give more memorable names to the elements of ;;; a pair contained in such a recipe: (define material car) (define parts cdr) ;;; The TOTAL-PARTS procedure takes a fertilizer mix as its arguments and ;;; returns the total number of parts for all of the constituents. (For ;;; instance, (TOTAL-PARTS BASIC-ALL-PURPOSE-FERTILIZER) is 10 -- ;;; 1 + 2 + 3 + 4.) (define total-parts (lambda (mix) (if (null? mix) 0 (+ (total-parts (car mix)) (total-parts (cdr mix)))))) ;;; The NITROGEN-PERCENTAGE procedure takes a fertilizer mix as its ;;; argument and computes the percentage of nitrogen in the mix (by ;;; weight): (define nitrogen-percentage (lambda (mix) (nitrogen-percentage-kernel mix (total-parts mix)))) (define nitrogen-percentage-kernel (lambda (rest-of-mix total) (if (null? rest-of-mix) 0.0 (+ (/ (* (parts (car rest-of-mix)) (nitrogen-part (assoc (material (car rest-of-mix)) composition)) total)) (nitrogen-percentage-kernel (cdr rest-of-mix) total))))) ;;; Similarly, the PHOSPHORUS-PERCENTAGE and POTASSIUM-PERCENTAGE ;;; procedures compute the percentages of phosphorus and potassium in the ;;; mix. (define phosphorus-percentage (lambda (mix) (phosphorus-percentage-kernel mix (total-parts mix)))) (define phosphorus-percentage-kernel (lambda (rest-of-mix total) (if (null? rest-of-mix) 0.0 (+ (/ (* (parts (car rest-of-mix)) (phosphorus-part (assoc (material (car rest-of-mix)) composition)) total)) (phosphorus-percentage-kernel (cdr rest-of-mix) total))))) (define potassium-percentage (lambda (mix) (potassium-percentage-kernel mix (total-parts mix)))) (define potassium-percentage-kernel (lambda (rest-of-mix total) (if (null? rest-of-mix) 0.0 (+ (/ (* (parts (car rest-of-mix)) (potassium-part (assoc (material (car rest-of-mix)) composition)) total)) (potassium-percentage-kernel (cdr rest-of-mix) total)))))