aboutsummaryrefslogtreecommitdiffstats
path: root/utils.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2021-12-17 13:25:23 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2021-12-17 13:25:23 +0200
commit63c1f74fe9a20984f6a19c3c2344793b1ed10072 (patch)
tree31c284f7a084bc6260a5134a781b656279e66ce1 /utils.hs
parent9578bb135a7cc00262281e448a151175b0825e7c (diff)
Day 17
Diffstat (limited to 'utils.hs')
-rw-r--r--utils.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/utils.hs b/utils.hs
index 9fcc553..3e6c2b6 100644
--- a/utils.hs
+++ b/utils.hs
@@ -39,4 +39,8 @@ splitToPair f lst =
in (x', y')
count :: (a -> Bool) -> [a] -> Int
-count pred xs = xs $> filter pred .> length \ No newline at end of file
+count pred xs = xs $> filter pred .> length
+
+takeUntil :: (a -> Bool) -> [a] -> [a]
+takeUntil _ [] = []
+takeUntil p (x : xs) = x : if p x then takeUntil p xs else []