Microsoft Store
 

Algol


 

ALGOL (short for ALGOrithmic Language) is a family of imperative computer programming languages originally developed in the mid 1950s which became the de facto standard way to report algorithms in print for almost the next 30 years. It was designed to avoid some of the perceived problems with FORTRAN and eventually gave rise to many other programming languages (including Pascal). ALGOL uses bracketed statement blocks and was the first language to use begin end pairs for delimiting them. Fragments of ALGOL-like syntax are sometimes still used as a notation for algorithms, so-called Pidgin Algol.

Code sample (ALGOL 60)

(The way the bolded text has to be written depends on the implementation, e.g. 'INTEGER' (including the quotation marks) for integer.)

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

procedure Absmax(a) Size:(n, m) Result:(y) Subscripts:(i, k);

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

value n, m; array a; integer n, m, i, k; real y;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

comment The absolute greatest element of the matrix a, of size n by m

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

is transferred to y, and the subscripts of this element to i and k;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

begin integer p, q;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

y := 0; i := k := 1;

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

for p:=1 step 1 until n do

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

for q:=1 step 1 until m do

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

if abs(a) > y then

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

begin y := abs(a);

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

i := p; k := q

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

end

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

end Absmax

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Here's an example of how to produce a table using Elliott 803 ALGOL.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

FLOATING POINT ALGOL TEST'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

BEGIN REAL A,B,C,D'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

READ D'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

FOR A:= 0.0 STEP D UNTIL 6.3 DO

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

BEGIN

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

PRINT PUNCH(3),££L??'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

B := SIN(A)'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

C := COS(A)'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

PRINT PUNCH(3),SAMELINE,ALIGNED(1,6),A,B,C'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

END'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

END'

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

PUNCH(3) sends output to the teleprinter rather than the tape punch.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

SAMELINE supresses the carriage return + line feed normally printed between arguments.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

ALIGNED(1,6) controls the format of the output with 1 digit before and 6 after the decimal point.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~