(*---------------------------------------------------------------------*) (* define pi as a constant *) (*---------------------------------------------------------------------*) val pi = 3.14159; (*---------------------------------------------------------------------*) (* convert yards to feet *) (*---------------------------------------------------------------------*) fun yards2feet (yards:real) = yards * 3.0; (*---------------------------------------------------------------------*) (* square a real number *) (*---------------------------------------------------------------------*) fun square_real (x:real) = x*x; (*---------------------------------------------------------------------*) (* convert square feet to acres *) (*---------------------------------------------------------------------*) fun feetsq2acres (feetsq:real) = feetsq / 43560.0; (*---------------------------------------------------------------------*) (* compute the area of a circle in acres, given its diameter in yards *) (*---------------------------------------------------------------------*) fun circle_area1 (diameter_yds:real) = feetsq2acres ( pi * square_real ( yards2feet ( diameter_yds/2.0 ))); (*---------------------------------------------------------------------*) (* compute the area of a circle in acres, given its diameter in yards *) (*---------------------------------------------------------------------*) fun circle_area2 (diameter_yds:real) = let val radius_yds = diameter_yds / 2.0; val radius_ft = yards2feet(radius_yds); val radius_sq = square_real(radius_ft); val area_ftsq = pi * radius_sq; in feetsq2acres (area_ftsq) end; (*---------------------------------------------------------------------*) (* compute the area of a rectangle in acres, given its dimensions in *) (* yards *) (*---------------------------------------------------------------------*) fun rect_area (width:real, length:real) = let val width_ft = yards2feet(width); val length_ft = yards2feet(length); val area_ftsq = width_ft * length_ft; in feetsq2acres (area_ftsq) end;