[Oberon] Eliminating RETURN statements

Hans Klaver hklaver at dds.nl
Thu Apr 9 00:27:00 CEST 2020


Karl and Diego,

Thanks for your proposal and comment. 
I agree with Diego that Karl's version of the algorithm is the most concise and perspicuous one, giving the correct reference output.

> Diego Sardina wrote:
> 
> August Karlstrom wrote:

>> 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;
>> 
> 
> This is the best way to write the algorithm, by putting the post-condition expression in the RETURN part.

--
Hans Klaver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20200409/ed705a6a/attachment.html>


More information about the Oberon mailing list