Method: LazyList::Enumerable#select
- Defined in:
- lib/lazylist/enumerable.rb
#select(&block) ⇒ Object Also known as: find_all
Returns a lazy list of all elements of this lazy list for which block is true.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/lazylist/enumerable.rb', line 80 def select(&block) block = All unless block s = self ended = catch(:end_list) do until s.empty? or block[s.head] s = s.tail end end if s.empty? or ended == :end_list empty else self.class.new(delay { s.head }) { s.tail.select(&block) } end end |