Method: Immutable::List#zip
- Defined in:
- lib/immutable/list.rb
#zip(others) ⇒ List
Combine two lists by “zipping” them together. The corresponding elements from this List and each of others (that is, the elements with the same indices) will be gathered into lists.
If others contains fewer elements than this list, nil will be used for padding.
409 410 411 412 413 414 |
# File 'lib/immutable/list.rb', line 409 def zip(others) LazyList.new do next self if empty? && others.empty? Cons.new(Cons.new(head, Cons.new(others.head)), tail.zip(others.tail)) end end |