diff options
author | Joe Zhao <ztuowen@gmail.com> | 2014-08-09 10:58:03 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2014-08-09 10:58:03 +0800 |
commit | 5bdaa1e4ffe40add10f000ee993e6b500c419a37 (patch) | |
tree | 46a624488ece8d37fa3580422234ed2b4acc6728 /shape.hs | |
parent | 01aa73b269f7ad780233be338affdf3c9288b1ed (diff) | |
download | haskbox-old-5bdaa1e4ffe40add10f000ee993e6b500c419a37.tar.gz haskbox-old-5bdaa1e4ffe40add10f000ee993e6b500c419a37.tar.bz2 haskbox-old-5bdaa1e4ffe40add10f000ee993e6b500c419a37.zip |
add files from home for previous chapters and sandboxes
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) |