title: filtering values into two lists
body: <p>So i'm new to sml and am trying to understand the ins/out out of it. Recently i tried creating a filter which takes two parameters: a function (that returns a boolean), and a list of values to run against the function. What the filter does is it returns the list of values which return true against the function.</p>
  
  <p>Code:</p>
  
  <pre><code>fun filter f [] = []  |
     filter f (x::xs) =
        if (f x)
        then x::(filter f xs)
        else (filter f xs);
  </code></pre>
  
  <p>So that works. But what i'm trying to do now is just a return a tuple that contains the list of true values, and false. I'm stuck on my conditional and I can't really see another way. Any thoughts on how to solve this?</p>
  
  <p>Code: </p>
  
  <pre><code>fun filter2 f [] = ([],[])  |
     filter2 f (x::xs) =
        if (f x)
        then (x::(filter2 f xs), []) (* error *)
        else ([], x::(filter2 f xs)); (* error *)
  </code></pre>