blob: 04211ea952079377f799ef16a214a79990551981 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
module Utils where
import Control.Applicative (ZipList (ZipList, getZipList))
(.>) = flip (.)
($>) = flip ($)
infixr 6 $>
splitOn :: (Char -> Bool) -> String -> [String]
splitOn p s = case dropWhile p s of
"" -> []
s' -> w : splitOn p s''
where
(w, s'') = break p s'
transpose :: [[a]] -> [[a]]
transpose = getZipList . traverse ZipList
mapWithIndex :: (Num a1, Enum a1) => (a2 -> b) -> [a2] -> [(a1, 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
|