Given a positive integer, spell it out in the conlang I made.
Let \$n\$ be the inputted integer. \$n\$ shall be spelled out in the following specification. The entire spelling is case sensitive.
With the decimal expansion of \$n\$, let d be the least significant nonzero digit of \$n\$.
First, d shall be spelled out like this:
Second, an appropriate suffix (or a "particle" in linguistic sense?) will immediately follow. This is judged by two boolean conditions: (A) Whether d has any trailing zeros, and (B) whether d is not the only nonzero digit.
If neither holds, the suffix shall be
If only (A) holds, the suffix shall be
If only (B) holds, the suffix shall be
If both hold, the suffix shall be
Third, if (A) held, the length of the trailing zeros shall be spelled out recursively.
Finally, if (B) held, d and the trailing zeros shall be stripped off, and the remaining digits shall be spelled out recursively.
All words shall be intercalated by a single ASCII 0x20 whitespace.
Nofat Quneh Qunem
Kalom Qunem Kalem
Sohat Sohat Sohem
Panat Kalat Nofat Qunem
Pisat Pisat Piseh Qunem
Qunom Pisem Kalat Kalem
Kalom Telem Kalat Qunem
Quneh Soheh Qunem
Quneh Telat Sohem
I/O format is flexible. Standard loopholes apply.
As for input, those that are not positive integers fall in don't care situation.
As for output, trailing whitespaces are permitted, but leading whitespaces are not.
import Data.List import Numeric.Natural spellNDos :: Natural -> String spellNDos 0 = "" spellNDos n = go (reverse (show n)) where go "" = "" go str = let (zeros, digit:remaining) = partition ('0'==) str digitSpell = case digit of '1' -> "Qun" '2' -> "Pis" '3' -> "Tel" '4' -> "Kal" '5' -> "Pan" '6' -> "Soh" '7' -> "Set" '8' -> "Qok" _ -> "Nof" suffix = case (null zeros, null remaining) of (False, False) -> "om " (False, _ ) -> "eh " (_ , False) -> "at " _ -> "em " in digitSpell ++ suffix ++ spellNDos (genericLength zeros) ++ go remaining