Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
6
Task/Number-names/Icon/number-names-1.icon
Normal file
6
Task/Number-names/Icon/number-names-1.icon
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
link numbers # commas, spell
|
||||
|
||||
procedure main(arglist)
|
||||
every x := !arglist do
|
||||
write(commas(x), " -> ",spell(x))
|
||||
end
|
||||
37
Task/Number-names/Icon/number-names-2.icon
Normal file
37
Task/Number-names/Icon/number-names-2.icon
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
procedure spell(n) #: spell out integer (short scale)
|
||||
local m, i
|
||||
static scale
|
||||
initial {
|
||||
scale := [ "thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion","septillion"]
|
||||
every scale[i := 1 to *scale ] := [ integer(repl("999",i + 1)), -3 * i, " "||scale[i] ]
|
||||
push(scale,[999,2," hundred"])
|
||||
}
|
||||
|
||||
n := integer(n) | stop(image(n)," is not an integer")
|
||||
if n < 0 then return "negative " || spell(-n)
|
||||
if n <= 12 then return {
|
||||
"0zero,1one,2two,3three,4four,5five,6six,7seven,8eight,_
|
||||
9nine,10ten,11eleven,12twelve," ? {
|
||||
tab(find(n))
|
||||
move(*n)
|
||||
tab(find(","))
|
||||
}
|
||||
}
|
||||
else if n <= 19 then return {
|
||||
spell(n[2] || "0") ?
|
||||
(if ="for" then "four" else tab(find("ty"))) || "teen"
|
||||
}
|
||||
else if n <= 99 then return {
|
||||
"2twen,3thir,4for,5fif,6six,7seven,8eigh,9nine," ? {
|
||||
tab(find(n[1]))
|
||||
move(1)
|
||||
tab(find(",")) || "ty" ||
|
||||
(if n[2] ~= 0 then "-" || spell(n[2]) else "")
|
||||
}
|
||||
}
|
||||
else if n <= scale[i := 1 to *scale,1] then return { # generalize based on scale
|
||||
spell(n[1:scale[i,2]]) || scale[i,3] ||
|
||||
(if (m := n[scale[i,2]:0]) ~= 0 then " and " || spell(m) else "")
|
||||
}
|
||||
else fail # really big
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue