public
Created

  • Download Gist
Lazy.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14
> LazyEnumerator.new([1, 2, 3]).
map{|el| puts "add #{el}"; el + 1}.
map{|el| puts "mul #{el}"; el * 2}.
each{|el| puts el}
add 1
mul 2
4
add 2
mul 3
6
add 3
mul 4
8
=> #<FunTree::LazyEnumerator:0x100377520 @transformation=#<Proc:0x0000000100119cb0@./lazy_enumerator.rb:15>, @enumerable=#<FunTree::LazyEnumerator:0x100377778 @transformation=#<Proc:0x0000000100119cb0@./lazy_enumerator.rb:15>, @enumerable=#<FunTree::LazyEnumerator:0x100377b88 @transformation=#<Proc:0x000000010011d770@./lazy_enumerator.rb:6>, @enumerable=[1, 2, 3]>>>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.