title: Picking elements of a list until condition is met with Java 8 Lambdas
body: <p>I am trying to switch my mind to think the functional way and recently faced a situation in which I needed to pick up elements from a list until a condition is met and I could not find an easy natural way of achieving this. Obviously I am still learning.</p>
  
  <p>Say I have this list:</p>
  
  <pre><code>List&lt;String&gt; tokens = Arrays.asList("pick me", "Pick me", "pick Me",
      "PICK ME", "pick me and STOP", "pick me", "pick me and Stop", "pick me");
  
  // In a non lambdas was you would do it like below
  List&lt;String&gt; myTokens = new ArrayList&lt;&gt;();
  for (String token : tokens) {
      myTokens.add(token);
      if (token.toUpperCase().endsWith("STOP")) {
          break;
      }
  }
  </code></pre>
  
  <p>Thank you in advance for your inputs</p>
  
  <p>NOTE:
  Before publishing this I read <a href="https://stackoverflow.com/questions/20746429">Limit a stream by a predicate</a> but I could not see how I can adapt that answer to my problem. Any help would be appreciated thanks.</p>