Number names: Difference between revisions

m
→‎[[Number names#ALGOL 68]]: fix a missing CASE OUT, add GOTO to make compatable with official ALGOL 68 subset.
(Deleted AutoHotkey. If the example referred to is ever retrieved, it can be put here in place of the incorrect solution.)
m (→‎[[Number names#ALGOL 68]]: fix a missing CASE OUT, add GOTO to make compatable with official ALGOL 68 subset.)
Line 137:
=={{header|ALGOL 68}}==
<!-- # From: www.codecodex.com/wiki/index.php%3Ftitle%3DConvert_an_integer_into_words - site states it is GPL # -->
{{works with|ALGOL 68|Standard - no extensions to language used}}
 
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
 
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8.8d.fc9.i386]}}
<lang algol68>PROC number words = (INT n)STRING:(
# returns a string representation of n in words. Currently
Line 146 ⟶ 151:
[]STRING decades = []STRING
("twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")[@2];
 
PROC three digits = (INT n)STRING: (
# does the conversion for n from 0 to 999. #
Line 152 ⟶ 157:
INT units = n MOD 10;
(n >= 100|digits[n OVER 100] + " " + "hundred" + (n MOD 100 /= 0|" and "|"")|"") +
(tens /= 0|(tens = 1|teens[units]|decades[tens] + (units /= 0|"-"|""))|"") +
(units /= 0 AND tens /= 1 OR n = 0|digits[units]|"")
);
Line 164 ⟶ 169:
(u /= 0 OR n = 0|three digits(u)|"")
);
 
on logical file end(stand in, (REF FILE f)BOOL: GOTO stop iteration);
on value error(stand in, (REF FILE f)BOOL: GOTO stop iteration);
DO # until user hits EOF #
INT n;