Short-circuit evaluation: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: fix markup) |
|||
Line 2,025: | Line 2,025: | ||
a: 0 |
a: 0 |
||
b: 1</lang> |
b: 1</lang> |
||
=={{header|Modula-2}}== |
|||
<lang modula2>MODULE ShortCircuit; |
|||
FROM FormatString IMPORT FormatString; |
|||
FROM Terminal IMPORT WriteString,WriteLn,ReadChar; |
|||
PROCEDURE a(v : BOOLEAN) : BOOLEAN; |
|||
VAR buf : ARRAY[0..63] OF CHAR; |
|||
BEGIN |
|||
FormatString(" # Called function a(%b)\n", buf, v); |
|||
WriteString(buf); |
|||
RETURN v |
|||
END a; |
|||
PROCEDURE b(v : BOOLEAN) : BOOLEAN; |
|||
VAR buf : ARRAY[0..63] OF CHAR; |
|||
BEGIN |
|||
FormatString(" # Called function b(%b)\n", buf, v); |
|||
WriteString(buf); |
|||
RETURN v |
|||
END b; |
|||
PROCEDURE Print(x,y : BOOLEAN); |
|||
VAR buf : ARRAY[0..63] OF CHAR; |
|||
VAR temp : BOOLEAN; |
|||
BEGIN |
|||
FormatString("a(%b) AND b(%b)\n", buf, x, y); |
|||
WriteString(buf); |
|||
temp := a(x) AND b(y); |
|||
FormatString("a(%b) OR b(%b)\n", buf, x, y); |
|||
WriteString(buf); |
|||
temp := a(x) OR b(y); |
|||
WriteLn; |
|||
END Print; |
|||
BEGIN |
|||
Print(FALSE,FALSE); |
|||
Print(FALSE,TRUE); |
|||
Print(TRUE,TRUE); |
|||
Print(TRUE,FALSE); |
|||
ReadChar |
|||
END ShortCircuit.</lang> |
|||
=={{header|MUMPS}}== |
=={{header|MUMPS}}== |