<div dir="ltr">
On Mon, Jul 22, 2019 at 4:16 PM Julian Fondren <<a href="mailto:jfondren@minimaltype.com" target="_blank">jfondren@minimaltype.com</a>> wrote:<br>
> % Mercury stdlib seems to have settled on this style.<br>
> % the initial 'if' looks unbalanced vs. the rest of the code.<br>
> daytype(D) = R :-<br>
> ( if D = wednesday then<br>
> R = "humpday"<br>
> else if (D = sunday; D = saturday) then<br>
> R = "weekend"<br>
> else<br>
> R = "workday"<br><div>
> ). <br></div><div><br></div><div>The usual way I write it is:</div><div><br></div><div>( if</div><div>
D = wednesday <br></div><div>then</div><div>
R = "humpday" <br></div><div>else if</div><div>
(D = sunday; D = saturday)</div><div>
then</div><div> R = "weekend"</div><div>else</div><div>
R = "workday"
</div><div>)</div><div><br></div><div>This keeps the arms mostly balanced, although it does take more</div><div>vertical space. Although I also really think that using full</div><div>
disjunctions is really usually preferable to if/then/else, and for this</div><div>example I would probably have just written a series of rules each</div><div>unifying a single weekday value.<br></div><div><br></div></div>