diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-12-27 14:09:22 +0100 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-12-27 14:09:22 +0100 |
commit | 833fcf24d661ef600d00c017ce7796b2fc938a17 (patch) | |
tree | 6e87577f23113e3be18fec3c6b297a9fbdc2dbb2 /2020/Util.hs | |
parent | a03c0ce5608b23a351886efbbeaa30cef19c284f (diff) |
Day 20
Diffstat (limited to '2020/Util.hs')
-rw-r--r-- | 2020/Util.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/2020/Util.hs b/2020/Util.hs index 7f5f941..7cd674d 100644 --- a/2020/Util.hs +++ b/2020/Util.hs @@ -1,5 +1,6 @@ module Util where +import Data.List import Data.List.NonEmpty (NonEmpty(..), (<|)) @@ -8,3 +9,6 @@ splitOn _ [] = [] :| [] splitOn f (x:xs) | f x = [] <| splitOn f xs | otherwise = let l :| ls = splitOn f xs in (x : l) :| ls + +splits' :: [a] -> [(a, [a])] +splits' l = zip l (zipWith (++) (inits l) (tail (tails l))) |