title: F# Split list into sublists based on comparison of adjacent elements
body: <p>I've found <a href="http://cs.hubfs.net/forums/thread/6291.aspx" rel="noreferrer">this question</a> on hubFS, but that handles a splitting criteria based on individual elements. I'd like to split based on a comparison of adjacent elements, so the type would look like this:</p>
  
  <pre><code>val split = ('T -&gt; 'T -&gt; bool) -&gt; 'T list -&gt; 'T list list
  </code></pre>
  
  <p>Currently, I am trying to start from Don's imperative solution, but I can't work out how to initialize and use a 'prev' value for comparison. Is fold a better way to go?</p>
  
  <pre><code>//Don's solution for single criteria, copied from hubFS
  let SequencesStartingWith n (s:seq&lt;_&gt;) =
      seq { use ie = s.GetEnumerator()
            let acc = new ResizeArray&lt;_&gt;()
            while ie.MoveNext() do
               let x = ie.Current
               if x = n &amp;&amp; acc.Count &gt; 0 then
                   yield ResizeArray.to_list acc
                   acc.Clear()
               acc.Add x
            if acc.Count &gt; 0 then
                yield  ResizeArray.to_list acc }
  </code></pre>