title: Scala: Apply same function to 2 lists in one call
body: <p>let say I have </p>
  
  <pre><code>val list: List[(Int, String)] = List((1,"test"),(2,"test2"),(3,"sample"))
  </code></pre>
  
  <p>I need to partition this list in two, based on (Int, String) value. So far, so good. 
  For example it can be </p>
  
  <pre><code>def isValid(elem: (Int, String)) = elem._1 &lt; 3 &amp;&amp; elem._2.startsWith("test")
  val (good, bad) = list.partition(isValid)
  </code></pre>
  
  <p>So, now I had 2 lists with signatures List[(Int, String)], but I need only Int part(some id). Off course I can write some function</p>
  
  <pre><code>def ids(list:List(Int, String)) = list.map(_._1)
  </code></pre>
  
  <p>and call it on both lists</p>
  
  <pre><code>val (ok, wrong) = (ids(good), ids(bad))
  </code></pre>
  
  <p>it worked, but looks little bit boilerplate. I prefer something like</p>
  
  <pre><code>val (good, bad) = list.partition(isValid).map(ids)
  </code></pre>
  
  <p>But it obviously not possible. So is there "Nicer" way to do what I need? 
  I understand that it's not so bad, but feel that there exist some functional pattern or general solution for such cases and I want to know it:) Thanks!</p>
  
  <p>P.S. Thanks for all! Finally it's transformed to </p>
  
  <pre><code>private def handleGames(games:List[String], lastId:Int) = {
    val (ok, wrong) = games.foldLeft(
    (List.empty[Int], List.empty[Int])){
      (a, b) =&gt; b match {
        case gameRegex(d,w,e) =&gt; {
          if(filterGame((d, w, e), lastId)) (d.toInt :: a._1, a._2)
          else (a._1, d.toInt :: a._2 )
        }
        case _ =&gt; log.debug(s"not handled game template is: $b"); a
      }
    }
    log.debug(s"not handled game ids are: ${wrong.mkString(",")}")
    ok
  }
  </code></pre>