Code: Select all
MODULE TestCP;
CONST
max* = MAX(INTEGER, 0);
END TestCP.
Code: Select all
MODULE TestCP;
CONST
max* = MAX(INTEGER, 0);
END TestCP.
Code: Select all
ELSIF (fctno = minfn) OR (fctno = maxfn) THEN
IF (parno < 1) OR (parno = 1) & (p.hint # 1) THEN err(65)
(* add this branch *) ELSIF (p.hint = 1) & (parno > 1) THEN err(64)
END;
Code: Select all
MAX(x, y) <= INTEGER INTEGER the larger value of x and y
integer type LONGINT
<= SHORTREAL SHORTREAL
numeric type REAL
SHORTCHAR SHORTCHAR
character type CHAR
MIN(x, y) <= INTEGER INTEGER the smaller of x and y
integer type LONGINT
<= SHORTREAL SHORTREAL
numeric type REAL
SHORTCHAR SHORTCHAR
character type CHAR
Code: Select all
CONST
max* = MAX("s", "a"); <-- operand inapplicable to (this) function
Code: Select all
VAR c1, c2: CHAR;
BEGIN
c1 := MIN(c1, c2);
Code: Select all
| min:
- IF f IN intSet + realSet THEN
+ IF f IN intSet + realSet + charSet THEN
| max:
- IF f IN intSet + realSet THEN
+ IF f IN intSet + realSet + charSet THEN
Code: Select all
MAX(INTEGER, 0)
Code: Select all
The following table lists the predeclared procedures. Some are generic procedures, i.e., they apply to several types of operands. v stands for a variable, x and y for expressions, and T for a type. The first matching line gives the correct result type.
Code: Select all
| minfn: (*MIN*)
IF p.hint # 1 (*p.class # Ntype*) THEN Op(min, p, x) ELSE err(64) END
| maxfn: (*MAX*)
IF p.hint # 1 (*p.class # Ntype*) THEN Op(max, p, x) ELSE err(64) END
Code: Select all
MODULE ObxMAX;
IMPORT Log:=StdLog;
PROCEDURE Do();
VAR x,y:INTEGER;b:BOOLEAN;
BEGIN
(* invalid*)
x := MAX(INTEGER, 0);
x := MAX(INTEGER, y);
x := MAX(0, INTEGER);
x := MAX(y, INTEGER);
x := MIN(INTEGER, 0);
x := MIN(INTEGER, y);
x := MIN(0, INTEGER);
x := MIN(y, INTEGER);
(*valid*)
x := MAX(INTEGER);
x := MAX(x, 0);
x := MAX(x, y);
x := MIN(INTEGER);
x := MIN(x, 0);
x := MIN(x, y);
END Do;
END ObxMAX.
Code: Select all
MAX(T) T = basic type T maximum value of type T
T = SET INTEGER maximum element of a set