Spoken Numbers by m.ukai

let d,p,t,o,r,s,e,i=1000,print_string,"teen","illion","six","seven","eigh","nine"let rec(@)n x=n/x*x<n&p" "=();f(n mod x)and f=function
1000000000->p("one b"^o)|n when n>=d*d->(f(n/d/d);p" m";p o;n@d*d)|n when n>=d->(f(n/d);p" thousand";n@d)|n when n>=100->(f(n/100);p" hundred";n@100)|n when n>=20->(p[|"twen";"thir";"for";"fif";r;s;e;i|].(n/10-2);p"ty";n@10)|n->p[|"";"one";"two";"three";"four";"five";r;s;e^"t";i;"ten";"eleven";"twelve";"thir"^t;"four"^t;"fif"^t;r^t;s^t;e^t;i^t|].(n);;while 1=1do
f(read_int());p"
"done

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page