Methods by type

polymod — successive division

Full

Break a number into mixed-radix parts in one call — seconds into h/m/s, etc.

.polymod divides a number by a series of moduli in turn, returning the remainder at each step and the final quotient. It's the clean way to convert a total into mixed-radix units.

Time from seconds #

3723.polymod(60, 60) peels off seconds, then minutes, leaving hours: 3 seconds, 2 minutes, 1 hour.

say 3723.polymod(60, 60);
Output
(3 2 1)

The general shape #

Each modulus divides the running quotient; the last element is whatever remains.

say 10.polymod(3);
Output
(1 3)

10 mod 3 is 1 (first element); the quotient 3 is the last.

Notes #