Haskell filter/split list
haskell, list
Solution
You are looking for the `partition` function from `Data.List`:
partition :: (a -> Bool) -> [a] -> ([a], [a])
It can be implemented nicely using a fold:
splitBy pred = foldr f ([], [])
where f x ~(yes, no) = if pred x then (x : yes, no)
else (yes, x : no)
Problem
I want something like ``` splitBy pred list = ( filter pred list, filter (not . pred) list ) ``` but in one pass.