[Oberon] Eliminating RETURN statements
August Karlstrom
fusionfile at gmail.com
Wed Apr 8 20:29:47 CEST 2020
On 2020-04-08 01:30, Hans Klaver wrote:> (* Oberon-07, right output *)
> PROCEDURE Fit (i, j: INTEGER): BOOLEAN;
> VAR k: INTEGER; OK: BOOLEAN;
> BEGIN
> k := 0; OK := TRUE;
> WHILE (k <= piecemax[i]) & OK DO
> IF p[i][k] THEN
> IF puzzl[j + k] THEN OK := FALSE END
> END;
> INC(k)
> END
> RETURN OK
> END Fit;
Here is an alternative:
PROCEDURE Fit (i, j: INTEGER): BOOLEAN;
VAR k: INTEGER;
BEGIN
k := 0;
WHILE (k <= piecemax[i]) & ~(p[i, k] & puzzl[j + k]) DO
INC(k)
END
RETURN k > piecemax[i]
END Fit;
-- August
More information about the Oberon
mailing list