ã Usage: fallsong n for American version starting at n bottles.
ã takesong n for British version
ã eM n - general utility which returns english version of n.
ã Note: Definition of billion, trillion, etc. follow American usage.
ã Limits: Some counting and reporting problems caused by comparison
ã tolerance and floating-point numbers above one trillion.
ã Absolute limit: Approximately 9.9998354e65, at which point
ã floating-point representation becomes unreliable.
ewd1û("zero";"one";"two";"three";"four";"five";"six";"seven";"eight";"nine";
"ten";"eleven";"twelve";"thirteen";"fourteen";"fifteen";"sixteen";
"seventeen";"eighteen";"nineteen")
ewd10û("";"";"twenty";"thirty";"forty";"fifty";"sixty";"seventy";
"eighty";"ninety"); ewdhû" hundred"; ewdcû" and ";
epowû("";" thousand")," ",¡("m";"b";"tr";"quadr";"quint";"sext";"sept";
"oct";"non";"dec";"undec";"duodec";"tredec";"quattuordec";"quindec";
"sexdec";"septendec";"octodec";"novemdec";"vigint"),¡<"illion"
eH n:if(20¤n){(t;xx)û0 10În;(tØewd10),if(0=xx)""else "-",xxØewd1} else nØewd1
eT n:if(100¤n){(h;x)û0 100În;(hØewd1),ewdh,if(0=x)""else ewdc,eH x}else eH n
eM n:{zû"";(iû#epow)do{(n;x)û0 1000În;if(0¨x)zû,(((100>x)^(i=0)^0¨n)/"and "),
(eTÄx),(iØepow),((0¨#z)/", "),z;if(0=n)ûz};z}
cap str:{nû`int©1Ùstr;if((97¤n)^122¦n)str[0]û`char©n-32;str}
nb n:(if(0¨n)(cap eM n)else "No more"),((-1=n)Õ" bottles")," of beer"
ootb n:if(1¨n)"one of those bottles"else"that bottle"
fate{b;n}:{if(b)".\nIf ",(ootb n)," should happen to fall,\n" else
".\nTake ",((1=n)Ø("one";"it"))," down; pass it around,\n"}
b stanza n:{wû" on the wall.";(nb n),w,"\n",(nb n),(b fate n),(nb n-1),w,"\n"}
fallsong n:{(iûn)do Õ1 stanza n-i;}
takesong n:{(iûn)do Õ0 stanza n-i;}