8 -- Stolen from ByteString. Splits a list at each element satisfying
10 splitWith :: (a -> Bool) -> [a] -> [[a]]
14 _:ws -> splitWith p ws
15 where (ys,zs) = break p xs
18 -- Pads a list (on the left) to length len by prepending pad_elem.
19 pad_left_to :: Int -> a -> [a] -> [a]
20 pad_left_to len pad_elem xs =
21 if (length xs) >= len then
24 (replicate padcount pad_elem) ++ xs
26 padcount = len - (length xs)
29 -- Pads a list (on the right) to length len by appending pad_elem.
30 pad_right_to :: Int -> a -> [a] -> [a]
31 pad_right_to len pad_elem xs =
32 if (length xs) >= len then
35 xs ++ (replicate padcount pad_elem)
37 padcount = len - (length xs)