title: Match to the n-th element of a list in Scala
body: <p>What is the best Scala idiom for matching a value to the n-th element of a list?</p>
  
  <p>The naive approach obviously doesn't work:</p>
  
  <pre><code>scala&gt; val list = List(5,6,7)
  list: List[Int] = List(5, 6, 7)
  
  scala&gt; val x = 7
  x: Int = 7
  
  scala&gt; x match { case list(2) =&gt; true; case _ =&gt; false }
  &lt;console&gt;:10: error: value list is not a case class constructor, nor does it have an       unapply/unapplySeq method
     x match { case list(2) =&gt; true; case _ =&gt; false }
  </code></pre>
  
  <p>To clarify- this question is not about how to compare a value to the n-th element of a list - it is specifically about whether it can be done using matching. </p>