On Jun 24, 7:05 am, "Robert Dober" <robert.do... / gmail.com> wrote: > Facets is great but Labrador is mine, what does that mean: I have the > luxury to do things that scale badly and break compatibility, -- I > have to make the documentation clear about this in the next version. > Facets is a General Purpose Library and cannot afford that luxury, so > it is very clear why you have #every -- a tempting idea not to > overload map, even in an experimental package as my dog package. Yet > another advantage, I just change the name, nobody can complain... > OTH I am surprised that #every corresponds to #map, from its naming on > would say it should correspond to #each. Yes, but #each is taken too ;) I though about #each? though. > > module Enumerable > > def every > > @_functor_every ||= Functor.new do |op,*args| > > self.collect{ |a| a.send(op,*args) } > > end > > end > > end > > I gotta look at your Functors again, maybe I can steal a little bit from you;) Basic Functor is easy: class Functor private *instance_methods def initialize(&function) @function = function end def method_missing(sym,*args,&blk) @function.call(sym,*args,&blk) end end Facets' is a little more fleshed out than that, but that's all one needs. And I still think it worthy of inclusion in Ruby's standard library. > That is a good thing, and thanks for pointing it out, looking for a > different name for #map now ;) > Though, I have to admit I'm not quite sure what a #map based> Enumerator is good for -- when you run #each on it, it acts like > > #map !!! I may have a solution for you: require 'enumerator' class Enumerable::Enumerator def method_missing(sym,*args,&blk) each{ |x| x.send(sym,*args,&blk) } end end With 1.9+ you'll get what you want (mostly). For 1.8, you just need to override map to return the Enumerator (just like 1.9 does). Btw, if you do the same for #select: [1,2,3].select < 2 #=> [1] Oh, I am soooo tempted to put this in Facets. T.