diff options
Diffstat (limited to 'shape.hs')
-rw-r--r-- | shape.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/shape.hs b/shape.hs new file mode 100644 index 0000000..0f8eca1 --- /dev/null +++ b/shape.hs @@ -0,0 +1,6 @@ +data Shape = Circle Float Float Float | Rectangle Float Float Float Float + deriving (Show) + +area :: Shape -> Float +area (Circle _ _ r) = pi * r ^ 2 +area (Rectangle x1 y1 x2 y2) = (abs $ x1 - x2) * (abs $ y1 - y2) |