diff --git a/Utils.hs b/Utils.hs index d62a525..4c36888 100644 --- a/Utils.hs +++ b/Utils.hs @@ -3,3 +3,13 @@ module Utils where symbolic = (`elem` symbolic_ops) symbolic_ops = "!@#$%^&*+./<=>?\\^|:-~" + +-- doing 'partition f xs = (filter f xs, filter (not . f) xs)' is too +-- slow, cuz it would run same test twice on every paramter. I might +-- be wrong tho +partition :: (a -> Bool) -> [a] -> ([a], [a]) +partition _ [] = ([], []) +partition f (x:xs) + | f x = (x:pass, fail) + | otherwise = (pass, x:fail) + where (pass, fail) = partition f xs