summaryrefslogtreecommitdiff
path: root/Library/Stack.hs
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-04-08 15:06:40 +1000
committerJed Barber <jjbarber@y7mail.com>2014-04-08 15:06:40 +1000
commit03d38eb3190eb5e51fb18847fe0792013285bde5 (patch)
tree1060d26d3042b5c0c5b1c027fac45fe87f3d685a /Library/Stack.hs
parentf2c4e4614613ede497f19ef79dc7dc157eaca834 (diff)
Reorganising source code
Diffstat (limited to 'Library/Stack.hs')
-rw-r--r--Library/Stack.hs50
1 files changed, 0 insertions, 50 deletions
diff --git a/Library/Stack.hs b/Library/Stack.hs
deleted file mode 100644
index 99cd8e1..0000000
--- a/Library/Stack.hs
+++ /dev/null
@@ -1,50 +0,0 @@
-module Library.Stack (
- Stack,
- empty,
- at,
- pop,
- (<:>),
- size,
- diff
- ) where
-
-
-import Data.List
-
-
-data Stack a = Stack [a] deriving (Eq)
-
-
-instance Show a => Show (Stack a) where
- show (Stack x) = "Stack:\n" ++ intercalate "\n" (map (show) x) ++ "\n\n"
-
-
-infixr 9 <:>
-
-
-empty :: Stack a
-empty = Stack []
-
-
-at :: Stack a -> Int -> Maybe a
-at (Stack list) index =
- if (index < length list && index >= 0)
- then Just (list!!index)
- else Nothing
-
-
-pop :: Int -> Stack a -> Stack a
-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
-
-
-diff :: (Eq a) => Stack a -> Stack a -> Stack a
-diff (Stack one) (Stack two) = Stack (one \\ two)
-