Algol 68

Algol 68 was the much awaited revision of Algol 60. However, something went off-track during the development process and it met with less-than-universal-approval when it was finally announced. As you can see from the code below, it is not a revision of Algol 60, but a whole new language.

From Algol 68 we get the somewhat less than charming convention of spelling keywords backwards to terminate blocks of code. One wonders why "END" and not "NIGEB" at the end of a program. This convention was picked up by some of the "big names" in Computer Science, and was used in many papers. The practice was always viewed as comical by a large segment of the Computer Science population. It gave rise to papers like "'Do considered od' considered odder than 'do considered ob'" (David Harel, Sigplan notices, V. 15, No. 4, Apr. 1980, p. 75) and countless private jokes. One of my theory professors in graduate school joked that he was going to start ending all his proofs with "foorp" instead of qed.

This program runs on the Algol 68 Genie compiler although I had to remove the comments and capitalize all the keywords to get it to work. Also, the output does not print one-number-per-line as I expected, but it is readable.

86 loglA


BEGIN


INT i;


[0:1000]INT candidates;


FOR i FROM 0 BY 1 TO 1000


DO


candidates[i] := 1


OD;


candidates[0] := 0;


candidates[1] := 0;


i := 0;


WHILE i<1000


DO


WHILE (i<1000 & candidates[i] = 0)


DO


i := i + 1


OD;


IF i<1000 THEN


FOR j FROM 2 BY 1 WHILE j*i < 1000


DO


candidates[j*i] := 0


OD;


i := i + 1


FI


OD;


FOR i FROM 0 BY 1 TO 999


DO


IF candidates[i] /= 0 THEN


print((i, " is prime"))


FI


OD


END

Click Here for the actual code.