summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2021-12-15 19:41:19 +0100
committerTom Smeding <tom@tomsmeding.com>2021-12-15 19:41:19 +0100
commit8279401e0b85ae707542ad5f919ecacb43b5f914 (patch)
treebf38af498f73e9de0290152b19a6740c6b80765c
parent026fbe8686417faa3e13e01dfd738631813d6ecb (diff)
uniq in Util
-rw-r--r--2021/12.hs5
-rw-r--r--2021/13.hs5
-rw-r--r--2021/Util.hs5
3 files changed, 5 insertions, 10 deletions
diff --git a/2021/12.hs b/2021/12.hs
index 03b2d77..ba902dd 100644
--- a/2021/12.hs
+++ b/2021/12.hs
@@ -12,11 +12,6 @@ import Input
import Util
-uniq :: Eq a => [a] -> [a]
-uniq (x : y : xs) | x == y = uniq (y : xs)
- | otherwise = x : uniq (y : xs)
-uniq l = l
-
main :: IO ()
main = do
inp <- getInput 12
diff --git a/2021/13.hs b/2021/13.hs
index 8e6c664..26e7a6d 100644
--- a/2021/13.hs
+++ b/2021/13.hs
@@ -8,11 +8,6 @@ import Input
import Util
-uniq :: Eq a => [a] -> [a]
-uniq (x : y : xs) | x == y = uniq (y : xs)
- | otherwise = x : uniq (y : xs)
-uniq l = l
-
generate :: A.Ix i => (i, i) -> (i -> a) -> A.Array i a
generate bounds f = A.listArray bounds (map f (A.range bounds))
diff --git a/2021/Util.hs b/2021/Util.hs
index f021a88..1553c4c 100644
--- a/2021/Util.hs
+++ b/2021/Util.hs
@@ -13,3 +13,8 @@ splitOn f (x:xs) | f x = [] <| splitOn f xs
splits' :: [a] -> [(a, [a])]
splits' l = zip l (zipWith (++) (inits l) (tail (tails l)))
+
+uniq :: Eq a => [a] -> [a]
+uniq (x : y : xs) | x == y = uniq (y : xs)
+ | otherwise = x : uniq (y : xs)
+uniq l = l