On 8/30/06, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov> wrote:
>
> xmp 'Array.step(0,4)'
> xmp 'Array.step(0,-4)'
>
> xmp 'Array.step(1,5,2)'
> xmp 'Array.step(-1,-5,-2)'
>
> xmp 'Array.step 2'
> xmp 'Array.step -2'
>
> xmp 'Array.step(0,7){|i| 2 ** i}'
> xmp 'even = Array.step(9){|i| i.modulo(2).zero?}'

I think this would be a perfect use for the new automatic enumerators,
to avoid passing two opaque parameters to a method:

# to generate an array
5.upto(10).step(2).to_a

# or the other way around
5.step(2).upto(10).to_a

# or if you'd rather use a range
(5..10).step(2).to_a

# to step over an existing array
ary.step(3)
ary[0..5].step(2)

etc.

martin