From 5bdaa1e4ffe40add10f000ee993e6b500c419a37 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Sat, 9 Aug 2014 10:58:03 +0800 Subject: add files from home for previous chapters and sandboxes --- shape.hs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 shape.hs (limited to 'shape.hs') 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) -- cgit v1.2.3-70-g09d2