summaryrefslogtreecommitdiff
path: root/src/Util.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-11-17 20:28:44 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2023-11-18 20:03:24 +0100
commit88a7bb50033baab3c2d0eed7e4be868e8966300a (patch)
tree861631a1e5e7434b92a8f19ef8f7b783790e1d1f /src/Util.hs
parent5b908c86320ee73f2722c85f8a47fa03ec093c6c (diff)
Split to library and executable parts
Diffstat (limited to 'src/Util.hs')
-rw-r--r--src/Util.hs37
1 files changed, 0 insertions, 37 deletions
diff --git a/src/Util.hs b/src/Util.hs
deleted file mode 100644
index c69adee..0000000
--- a/src/Util.hs
+++ /dev/null
@@ -1,37 +0,0 @@
-module Util where
-
-uniq :: Eq a => [a] -> [a]
-uniq (x:y:xs) | x == y = uniq (x:xs)
- | otherwise = x : uniq (y:xs)
-uniq xs = xs
-
-mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a]
-mergeBy cmp (x : xs) (y : ys) = case cmp x y of
- LT -> x : mergeBy cmp xs (y : ys)
- EQ -> x : y : mergeBy cmp xs ys
- GT -> y : mergeBy cmp (x : xs) ys
-mergeBy _ xs [] = xs
-mergeBy _ [] ys = ys
-
-mergeUniqBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a]
-mergeUniqBy cmp (x : xs) (y : ys) = case cmp x y of
- LT -> x : mergeBy cmp xs (y : ys)
- EQ -> x : mergeBy cmp xs ys
- GT -> y : mergeBy cmp (x : xs) ys
-mergeUniqBy _ xs [] = xs
-mergeUniqBy _ [] ys = ys
-
-mergeUniq :: Ord a => [a] -> [a] -> [a]
-mergeUniq = mergeUniqBy compare
-
-diffSorted :: Ord a => [a] -> [a] -> [a]
-diffSorted (x:xs) (y:ys) | x < y = x : diffSorted xs (y:ys)
- | x > y = diffSorted (x:xs) ys
- | otherwise = diffSorted xs (y:ys)
-diffSorted xs _ = xs
-
-intersectsSorted :: Ord a => [a] -> [a] -> Bool
-intersectsSorted (x:xs) (y:ys) | x < y = intersectsSorted xs (y:ys)
- | x > y = intersectsSorted (x:xs) ys
- | otherwise = True
-intersectsSorted _ _ = False