title: Chopping up a list into a list of lists
body: <p>Suppose I have a list of elements <code>myl</code> and a function <code>f</code>. I would like to chop up <code>myl</code> into a list of lists, where each new "sublist" contains a contiguous stretch of <code>myl</code> on which the value of <code>f</code> is constant.</p>
  
  <p>For example, if <code>myl = List( (1,2), (3,2), (4,1), (6,2) )</code> and <code>def f(x: (Int, Int)) = x._2</code>. Then the result should be <code>List( List((1,2), (3,2)), List((4, 1)), List((6,2)) )</code>.</p>
  
  <p>Is there an elegant way to write such a function without any <code>var</code>s?</p>