title: Iterate over a list, returning the current, next and the element before current
body: <p>I have problems with writing an specific application in a scala-esque and elegant way. I tried this for some time now, but I cannot find a "good" solution to this Problem:</p>
  
  <p>Given that I have the following List:</p>
  
  <pre><code>List("foo", "bar", "baz", "blah")
  </code></pre>
  
  <p>I want to Iterate over this list, not only giving me the current element for each Iteration but also the element before and after the current element. This might be a Tuple3 but is not required to. This could be the Tuple signature:</p>
  
  <pre><code>(Option[T], T, Option[T])
  </code></pre>
  
  <p>To clarify what i mean, this is the proposed Tuple for each iteration over a <code>List[String]</code>, ending after the fourth.</p>
  
  <p>Iteration 1: <code>(None, "foo", Some("bar"))</code></p>
  
  <p>Iteration 2: <code>(Some("foo"), "bar", Some("baz"))</code></p>
  
  <p>Iteration 3: <code>(Some("bar"), "baz", Some("blah"))</code></p>
  
  <p>Iteration 4: <code>(Some("baz"), "blah", None)</code></p>
  
  <p>How could I achieve such a result? Again: I am not bound to the Tuple3, any other solution is also very appreciated!</p>
  
  <p>Thanks!</p>