Multi Radix Counter

DESCRIPTION:

Returns a vector that is current plus 1 relative to radix.

USAGE:

odometer(current, radix) 

REQUIRED ARGUMENTS:

current
integer vector; the current value of the counter.
radix
integer vector; the values at which each "wheel" of the odometer "turns over".

VALUE:

the next value of the counter. The counter is a vector of integers; the ith element is always non-negative and less than radix[i]. The first element of current is incremented; if it reaches radix[1] it is reset to zero and the second element of current is incremented, and so on.

DETAILS:

On the first call to odometer, current should generally be all zeros. odometer will return all zeros when it has completed its cycle.

EXAMPLES:

odometer(c(2, 1, 3), c(3, 3, 5)) # returns c(0, 2, 3) 
# a function that returns the next second 
# in seconds, minutes, hours 
next.second <- function(current.time) 
        odometer(current.time, c(60, 60, 24))