title: Find Indexes *Where*
body: <p>There's a <code>indexWhere</code> function in <code>Vector</code> that finds the index of a match.</p>
  
  <pre><code>def indexWhere(p: (A) ⇒ Boolean, from: Int): Int
  &gt; Finds index of the first element satisfying some predicate after or 
  &gt; at some start index.
  </code></pre>
  
  <p><a href="http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Vector" rel="noreferrer">http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.Vector</a></p>
  
  <p>I wrote this function to find <strong>all</strong> indexes where such a match occurs. </p>
  
  <pre><code>  def getAllIndexesWhere[A,B](as: List[A])(f: (B =&gt; Boolean))(g: A =&gt; B): Vector[B] = {
      def go(y: List[A], acc: List[Option[B]]): Vector[B] = as match {
        case x :: xs =&gt; val result = if (f(g(x))) Some(g(x)) else None
                        go(xs, acc :+ result)
        case Nil =&gt; acc.flatten.toVector
      }
      go(as, Nil)
    }
  </code></pre>
  
  <p>However, is there already a built-in function of a collection?</p>