title: Scala List.filter with two conditions, applied only once
body: <p>Don't know if this is possible, but I have some code like this:</p>
  
  <pre><code>val list = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
  val evens = list.filter { e =&gt; e % 2 == 0 }
  
  if(someCondition) {
    val result = evens.filter { e =&gt; e % 3 == 0 }
  } else {
    val result = evens.filter { e =&gt; e % 5 == 0 }
  }
  </code></pre>
  
  <p>But I don't want to iterate over all elements twice, so is there a way that I can create a "generic pick-all-the-evens numbers on this collection" and apply some other function, so that it would only iterate once?</p>