Most of the times we need Intermediate results to get the final outcome, By using where Clause we can define intermediate results.
Suppose if a Triangle has sides a, b and c. As per Herons’s formula, following formula is used to calculate area of triangle.
Where s is semi perimeter.
areaOfTriangle a b c = sqrt (s * (s - a) * (s - b) * (s - c))
s = (a + b + c) / 2
*Main> :load triangle.hs
[1 of 1] Compiling Main ( triangle.hs, interpreted )
Ok, modules loaded: Main.
*Main> areaOfTriangle 40 40 20
1. Find sum of squares of two numbers