[Oberon] Eliminating RETURN statements

Chris Burrows chris at cfbsoftware.com
Thu Apr 9 02:08:17 CEST 2020


> -----Original Message-----
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of August
> Karlstrom
> Sent: Thursday, 9 April 2020 4:00 AM
> To: oberon at lists.inf.ethz.ch
> Subject: Re: [Oberon] Eliminating RETURN statements
> 
> 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;
> 
> 

According to one of De Morgan's Laws 

i.e.   ~(A AND B) --> (~A OR ~B)

the WHILE expression can be simplified to:

    WHILE (k <= piecemax[i]) & (~p[i, k] OR ~puzzl[j + k]) DO

However, I'm not convinced this is simpler. What do you think?

Regards,
Chris Burrows
CFB Software
https://www.astrobe.com






More information about the Oberon mailing list