-- area (RtTriangle s1 s2) = s1 * s2 / 2
area (RtTriangle s1 s2) = abs (s1 * s2 / 2)
-- perimeter (RtTriangle s1 s2) = s1 + s2 + sqrt (s1 ^ 2 + s2 ^ 2)
perimeter (RtTriangle s1 s2) = abs s1 + abs s2 + sqrt (s1 ^ 2 + s2 ^ 2)
-- data Shape = RtTriangle Float Float
{-
Book's question: on section 8.2.2
How should we encode the meaning of a shape in Haskell?
It would seems foolhardy to try to build the entire set,
or list, of all of its points. (Why?)
Because there are infinity of points due to density of Real number.
(Ex. 0.0, 0.1, 0.01, 0.001, 0.0001, …. )
-}
This entry was posted
on Tuesday, May 29th, 2007 at 8:38 pm and is filed under Haskell - SOE.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.