AN EXAMPLE FROM TEACH ARITH SHOWING OUTPUT One of the examples in the TEACH ARITH file is the procedure ESTIMATE below for deriving perimeter, area, and volume information from measurements of a room's length, width and height. Some subroutines needed in the 'estimate' procedure, below. ;;; A procedure PERIM to compute room perimeter. define perim(long, wide) -> total; long + wide + long + wide -> total enddefine; ;;; A procedure FLOOR to compute floor area define floor(long, wide) -> area; long * wide -> area enddefine; ;;; A procedure to compute the total wall area of the room define wallarea(long, wide, high) -> total; perim(long, wide) * high -> total enddefine; ;;; Compute the volume of the room define volume(long, wide, high) -> vol; long * wide * high -> vol enddefine; ;;; Now a procedure to run all of those, if given measurements ;;; of length, width and height. define estimate(long, wide, high); lvars num; ;;; compute perimeter perim(long, wide) -> num; [ Your room has a perimeter of ^num feet] => ;;; compute wall area; wallarea(long, wide, high) -> num; [ You will need ^num square feet of wallpaper] => ;;; compute foor area floor(long, wide) -> num; [you will need ^num square feet of carpeting ] => ;;; compute volume to be heated volume(long, wide, high) -> num; [The radiator will have to cope with a volume of ^num cubic feet] => enddefine; Now test your procedure: estimate(10,10,10); That prints out: ** [Your room has a perimeter of 40 feet] ** [You will need 400 square feet of wallpaper] ** [you will need 100 square feet of carpeting] ** [The radiator will have to cope with a volume of 1000 cubic feet] Another test: estimate(8,12,8); ** [Your room has a perimeter of 40 feet] ** [You will need 320 square feet of wallpaper] ** [you will need 96 square feet of carpeting] ** [The radiator will have to cope with a volume of 768 cubic feet] And a big, high-ceilinged, hall: estimate(50,75,16); ** [Your room has a perimeter of 250 feet] ** [You will need 4000 square feet of wallpaper] ** [you will need 3750 square feet of carpeting] ** [The radiator will have to cope with a volume of 60000 cubic feet] QUESTIONS: Suppose the room was square, how could you simplify the procedures? Suppose the room was hexagonal shaped, how could you change the procedures? Aaron Sloman http://www.cs.bham.ac.uk/~axs 23 Jul 2009