module Lab42::Stream::Utility

Public Instance Methods

__segment__(beh) click to toggle source
# File lib/lab42/stream/utility.rb, line 9
def __segment__ beh
  if beh.( head )
    cons_stream( cons_stream( head ){  tail.lazy_take_until beh } ){
      tail.drop_until( beh ).__segment__ beh
    }
  else
    cons_stream( lazy_take_until beh ){
      tail.drop_until( beh ).__segment__ beh
    }
  end
end
segment(*args, &blk) click to toggle source
# File lib/lab42/stream/utility.rb, line 5
def segment *args, &blk
  __segment__ Behavior.make( *args, &blk )
end
with_index(start={}) click to toggle source
# File lib/lab42/stream/utility.rb, line 21
def with_index  start={}
  start = Hash === start ? start.fetch( :from, 0 ) : start
  zip_as_ary iterate( start, :succ )
end