|
|
|
|
|
by kjaer
3004 days ago
|
|
I wrote it in Scala below; it's a bit shorter, and I really like the map(base). Getting the digits from a number turns out to be most of the work, and the int->string->int conversion also seems to be the best approach. val base = List("noa", "taha", "ua", "tolu", "fa", "nima", "ono", "fitu", "valu", "hiva")
def tongan(n: Int) = n.toString.map(_.asDigit).map(base).mkString(" ")
|
|