I'm making a function that does
(a->Bool) -> [a] -> State [a] [a]
and I was wondering if there was a simple way to go through the list storing "failed" items that didn't pass the predicate as the state and the "passing" items as the value that will eventually be returned? You would see both the return value and the state. Samples:
*CL> runState (func (<3) [1, 2, 3]) []
([1, 2], [3])
*CL> runState (func even [1, 2, 3]) [10]
([2], [10, 1, 3])
I've looked long and hard for answers and haven't found anything on this specific situation yet. I know I can do it differently as I have, but I specifically want to know if I can do it in the way mentioned above.