Method: Immutable::List#chunk
- Defined in:
- lib/immutable/list.rb
#chunk(number) ⇒ List
Split the items in this list in groups of number. Return a list of lists.
726 727 728 729 730 731 732 |
# File 'lib/immutable/list.rb', line 726 def chunk(number) LazyList.new do next self if empty? first, remainder = split_at(number) Cons.new(first, remainder.chunk(number)) end end |