summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2012-09-27 18:50:16 +1000
committerJed Barber <jjbarber@y7mail.com>2012-09-27 18:50:16 +1000
commitad1b2ed1e8fb4ec549318a27b5f80d2a6651b2dd (patch)
tree3c96a247285d44685233a49df19bb51e4eb544b9
parent7e98e0d9bb1cdc895d124f3bebc00dadb4f99a9c (diff)
Stack datatype now deriving Eq
-rw-r--r--Library/Stack.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/Library/Stack.hs b/Library/Stack.hs
index 7292869..29dd17c 100644
--- a/Library/Stack.hs
+++ b/Library/Stack.hs
@@ -3,14 +3,15 @@ module Library.Stack (
empty,
at,
pop,
- (<:>)
+ (<:>),
+ size
) where
import Data.List
-data Stack a = Stack [a]
+data Stack a = Stack [a] deriving (Eq)
instance Show a => Show (Stack a) where
@@ -37,3 +38,7 @@ pop n (Stack list) = Stack (drop n list)
(<:>) :: a -> Stack a -> Stack a
x <:> (Stack list) = Stack (x : list)
+
+
+size :: Stack a -> Int
+size (Stack list) = length list