title: How to find the position of a value with foldLeft from a List?
body: <p>I have a List that contains, 1s and -1s. The goal I'm after is to find the position in the List when the total is -1. </p>
  
  <pre><code>List[Int] = List(1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, 
  -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1,
   1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1)
  </code></pre>
  
  <p>But my code is not working.</p>
  
  <p>Here are my attempts(I spaced the code out for better reading) Note: <b><code>floor</code></b> is the val that holds the List of Ints.</p>
  
  <pre><code>floor.foldLeft(0) { ( (x,y) =&gt; x+y == -1 ) }.indexOf(-1)
  
  floor.foldLeft(0) ( (x,y) =&gt; {  (x + y == -1) {x.indexOf(-1)} }  )
  
  floor.foldLeft(0) { (x,y) =&gt; { if (x + y == -1) { indexOf(-1) } } }
  </code></pre>
  
  <p>I'd like to know what I'm doing wrong here. I'm really after the why more than the answer in and of itself. </p>