Files
AoC2022/Lib.hs
Amneesh Singh 9d6a8e6aaf day3
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-03 16:23:21 +05:30

17 lines
303 B
Haskell

module Lib (chunks, split) where
chunks n xs
| null xs = []
| otherwise = head : chunks n tail
where (head, tail) = splitAt n xs
split :: Eq a => a -> [a] -> [[a]]
split del =
foldr
( \c (x : xs) ->
if c == del
then [] : x : xs
else (c : x) : xs
)
[[]]