diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2021-12-09 13:27:55 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2021-12-09 21:03:58 +0200 |
| commit | 48f9acaff1fbea7537edbeb91ce4d35e40314a43 (patch) | |
| tree | 09c1fed6576a3094f5289a860b451d92d7b524b4 /utils.hs | |
| parent | 6d6b2f27a0bef3a592be29dbb87d2f18c2f0c145 (diff) | |
Day 08
Diffstat (limited to 'utils.hs')
| -rw-r--r-- | utils.hs | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -18,8 +18,11 @@ splitOn p s = case dropWhile p s of transpose :: [[a]] -> [[a]] transpose = getZipList . traverse ZipList -mapWithIndex :: (Num a1, Enum a1) => (a2 -> b) -> [a2] -> [(a1, b)] +mapWithIndex :: (a -> b) -> [a] -> [(Int, b)] mapWithIndex f xs = zip [0 ..] (map f xs) removeAt :: [Int] -> [b] -> [b] removeAt is xs = mapWithIndex id xs $> filter (\(i', _) -> i' `notElem` is) .> map snd + +slice :: Int -> Int -> [a] -> [a] +slice from to xs = take (to - from + 1) (drop from xs)
\ No newline at end of file |
