Harry Ohlsen <harryo@qiqsolutions.com> wrote:
> I have a feeling that some kind of recursive method that returns a
> continuation might be the way to go, but I'm open to any suggestions,
> whatsoever.
Overkill - this should do it:

class MultiCounter
def initialize(a, b = nil)
@max = a
@min = b || a.map {0}
raise "max and min arrays should have the same length" unless @max.length ==
@min.length
@cur = @min
end

def next
inc (@cur.length - 1)
end

def inc(i)
return nil if i < 0
@cur[i] += 1
if @cur[i] > @max[i]
@cur[i] = 0
return inc(i - 1)
end
@cur
end
end

a = MultiCounter.new([3, 2, 2, 1])
while (b = a.next)
p b
end

martin