RosettaCodeData/Task/Number-names/Logo/number-names.logo
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

28 lines
1.1 KiB
Text

make "numbers {one two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen}
make "tens {twenty thirty forty fifty sixty seventy eighty ninety}@2
make "thou [[] thousand million billion trillion] ; expand as desired
to to.english.thou :n :thou
if :n = 0 [output []]
if :n < 20 [output sentence item :n :numbers first :thou]
if :n < 100 [output (sentence item int :n/10 :tens
to.english.thou modulo :n 10 [[]]
first :thou)]
if :n < 1000 [output (sentence item int :n/100 :numbers
"hundred
to.english.thou modulo :n 100 [[]]
first :thou)]
output (sentence to.english.thou int :n/1000 butfirst :thou
to.english.thou modulo :n 1000 :thou)
end
to to.english :n
if :n = 0 [output "zero]
if :n > 0 [output to.english.thou :n :thou]
[output sentence "negative to.english.thou minus :n :thou]
end
print to.english 1234567 ; one million two hundred thirty four thousand five hundred sixty seven