<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>m3front/misc/CG.m3<br><br><br>PROCEDURE Force_pair (commute: BOOLEAN): BOOLEAN =<br> (* Returns TRUE if the items are stacked in the wrong order *)<br> VAR s1 := stack [SCheck (1, "Force_pair")].kind = VKind.Stacked;<br> VAR s2 := stack [SCheck (2, "Force_pair")].kind = VKind.Stacked;<br> BEGIN<br> IF s1 AND s2 THEN<br> (* both elements are already stacked *)<br> RETURN FALSE;<br> ELSIF s2 THEN<br> (* bottom element is already stacked *)<br> Force ();<br> RETURN FALSE;<br> ELSIF s1 THEN<br> Swap ();<br> Force ();<br> IF commute THEN RETURN TRUE END;<br> Swap ();<br> RETURN FALSE;<br> ELSE (* neither element is stacked *)<br> Swap ();<br> Force ();<br> Swap ();<br> Force ();<br> RETURN FALSE;<br> END;<br> END Force_pair;<br><br><br>Shouldn't the last part be:<br><br> ELSE (* neither element is stacked *)<br> IF commute THEN<br> Force ();<br> Swap ();<br> Force ();<br> RETURN TRUE;<br> END;<br> Swap ();<br> Force ();<br> Swap ();<br> Force ();<br> RETURN FALSE;<br> END;<br><br>?<br><br><br>Probably there is a way to write the function with less duplication.<br><br><br> - Jay<br> </div></body>
</html>