On Tue, 25 May 2004, Yukihiro Matsumoto wrote:

> Hi,
> 
> In message "[RCR] Numeric#of"
>     on 04/05/25, "Ara.T.Howard" <ahoward / noaa.gov> writes:
> 
> |this got a generally favourable reception so:
> |
> |RCR - Numeric#of - an accumlative version of Numeric#times
> 
> What if n is very large number?


same problem with using #map vs. #map! isn't it?

> Besides that Numeric#of is not very intuitive for me (non native English
> speaker).  It seems too vague for me.  Is the name "of" really OK for you
> guys?
> 
> 							matz.

i'm not attached to 'of' - all i was suggesting was a collecting
Numeric#times.  i actually considered this first:

  ~ > cat a.rb
  class Numeric
    def inject accum = []
      times{|i| accum = yield(accum, i)}
      accum
    end
  end

  stacks = 3.inject{ [] }
  p stacks # [[],[],[]]

  hash = 16.inject({}){|h,i| h[i] = i; h}
  p hash[4] # => 4

but this is even less intuitive, whereas the 'of' why kindof reads like 'give
me n of these'.  sorry i can't think of a better non-english-centric name ;-)

-a
-- 
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL     :: http://www.ngdc.noaa.gov/stp/
| "640K ought to be enough for anybody." - Bill Gates, 1981
===============================================================================