summaryrefslogtreecommitdiffstats
path: root/foo.hs
diff options
context:
space:
mode:
Diffstat (limited to 'foo.hs')
-rw-r--r--foo.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/foo.hs b/foo.hs
new file mode 100644
index 0000000..0cdf3b6
--- /dev/null
+++ b/foo.hs
@@ -0,0 +1,21 @@
+foo :: [(Int, Int)]
+foo = [(8, 14), (4,2), (3,4)]
+
+findmin :: (Int, Int) -> (Int, Int) -> (Int, Int)
+findmin (a,b) (c,d)
+ | a < c = (a,b)
+ | otherwise = (c,d)
+
+minf :: [(Int, Int)] -> (Int, Int)
+minf (x:xs) = foldr findmin x xs
+
+minf2 :: [(Int, Int)] -> Int
+minf2 xs = b
+ where (a,b) = minf xs
+
+
+
+data Bar = Bar Int Int deriving (Eq,Show)
+
+instance Ord Bar where
+ (Bar _ s1) `compare` (Bar _ s2) = s1 `compare` s2