#> Wouldn't my algorithm slow down? Does not the chain begs for
#a single method
#> -which brings us back to the original question...?
#>
···
daz [mailto:dooby@d10.karoo.co.uk] wrote:
#
#Yes. I'm taking sedatives while it's seriously being considered that
#an Array should become an Enumerator in order to use its
##with_index method
#on an intermediate #map object to produce ... an Array ...
#instead of the
#regular #map method with an optional index.
#
#I would have posted a link to the ruby-core thread, but it was my
#first post to a mailing list and my MAIL settings were different
#from my NEWS settings, so it's messed up (quoted-printable MIME).
#
#Here's a text version (minor EDITs). I'm sure it'll be
#relevant to you.
#
# http://www.d10.karoo.net/ruby/xv/ruby-core-1495.txt
#
#You'll see examples using bang! methods.
#
#(( I'd be fascinated to see map!.with_index or map.with_index!
# produce anything intelligible using require 'enumerator'. ))
#
cool. you're a ruby hacker indeed.
but imho (my opinion only) i do not like the ||.x notation.
how about
# we only need the index
[1,2,3].each() {|i|* printf i,"\n"}
# we need the val and the index
[1,2,3].each() {|x,i|* printf x,i,"\n"}
# in other words, we always get the last param as the index
[[0,1],[1,2],[3,4]].each() {|x,y,i|* printf x,i,"\n"}
ie, we put a star after the param delimiters || to signal an index. It's
like telling the programmer/reader "*hint-hint*"
kind regards -botp
#daz
#
#
#
#