Wow, Tongan number system is simply beautiful. Pure elegance that I'm sure could be defined mathematically very simply. I myself can only scribble a naive implementation for natural numbers in Javascript:
const base = ["noa", "taha", "ua", "tolu", "fa", "nima", "ono", "fitu", "valu", "hiva"]
const tongan = n => Array.from(n.toString()).map(Number).map(i => base[i]).join(" ")
Not as pretty as I thought. Probably would look better in functional language.