How do I take a list in haskell and produce two lists as an output?
For example a question I am working on asks to create a program that takes a predicate and a list and returns a list of two lists, the first those elements of the input list which pass the predicate, the second those that don't, in order, e.g
tear (>5) [1,10,2,12,3,13]
=> [[10,12,13],[1,2,3]]
What i have so far:
tear f [] = []
tear f (x:xs)
| f x = x: tear f xs
| otherwise = tear f xs
Which produces
tear (>5) [1,10,2,12,3,13]
[10,12,13]