Method: Rupture::Sequence#partition_between

Defined in:
lib/rupture/sequence.rb

#partition_between(f = nil, &fn) ⇒ Object



276
277
278
279
280
281
282
283
284
285
# File 'lib/rupture/sequence.rb', line 276

def partition_between(f = nil, &fn)
  fn ||= f
  F.lazy_seq do
    if s = seq
      run = F.cons(s.first,
                   s.partition(2,1).take_while {|i| not fn[*i]}.map(:second))
      F.cons(run, s.drop(run.count).partition_between(fn))
    end
  end
end