Exercise 2.1: Three Circles

Given: an array of three real values, r, for the radii of three circles;
Compose: a let-in statement that returns two arrays containing the areas and circumferences of the circles of the given radii.
let pi := 3.14159;
    area1 :=  r[1] * r[1] * pi;
    area2 :=  r[2] * r[2] * pi;
    area3 :=  r[3] * r[3] * pi;
    circ1 := 2.0 * r[1] * pi;
    circ2 := 2.0 * r[2] * pi;
    circ3 := 2.0 * r[3] * pi;

in  array [ 1: area1, area2, area3 ],
    array [ 1: circ1, circ2, circ3 ]
end let


Previous Section