From: Trans Date: 2008-11-03T04:13:18+09:00 Subject: Re: ruby1.9: lazy versions of Enumerator#select and friends? On Nov 2, 11:41 am, Brian Candler wrote: > I've been having a play with Enumerators in ruby 1.9, in particular > adding 'lazy' versions of those methods in Enumerable which normally > return arrays. Here's a proof-of-concept implementation: > > module Enumerable >   def lmap(&blk) >     Enumerator.new do |y| >       each do |e| >         y << blk[e] >       end >     end >   end This doesn't work. But I think I understand what you are after. Wouldn't it have to be something like: def lmap(&blk) this = self Functor.new |op, &blk| # &blk in 1.9 only :( this.map(&blk).__send__(op, &blk) end end T.