title: Lazily split Iterable on condition
body: <p>I'm having problems trying to create a function that lazily separates an iterable into sub-iterables given a condition.</p>
  <p>Here's what I have so far</p>
  <pre class="lang-py prettyprint-override"><code>def split_on_condition(
          seq: t.Iterable[T], condition: t.Callable[[T], bool]
  ) -&gt; t.Iterable[t.Iterable[T]]:
      curr = []
      for i in seq:
          if condition(i):
              curr.append(i)
          else:
              yield curr
              curr = []
      yield curr
  
  
  foo = ('a', 'b', 'c', '', '...rest')
  print(list(split_on_condition(foo, bool)))
  
  # [['a', 'b', 'c'], ['...rest']]
  </code></pre>
  <p>So this <em>works</em>, which is nice; but the problem is that <code>curr</code> is a <em>list</em>, rather I want it to be lazy evaluation so that I could use an arbitrarily large sequence as input.</p>
  <pre class="lang-py prettyprint-override"><code>from itertools import repeat
  
  for _ in split_on_condition(repeat('oops, infinite loop'), bool):
      pass
      # Program will crash here :(
  
  </code></pre>