ALGOL 68 - Notable Language Elements - Op: Operators

Op: Operators

The programmer may define new operators and both those and the pre-defined ones may be overloaded and their priorities may be changed by the coder. The following example defines operator max with both dyadic and monadic versions (scanning across the elements of an array).

prio max = 9; op max = (int a,b) int: ( a>b | a | b ); op max = (real a,b) real: ( a>b | a | b ); op max = (compl a,b) compl: ( abs a > abs b | a | b ); op max = (real a) real: (real out := a; for i from lwb a + 1 to upb a do ( a>out | out:=a ) od; out)

Read more about this topic:  ALGOL 68, Notable Language Elements