Short-circuit evaluation: Difference between revisions

m
No edit summary
Line 2,391:
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
Module Short_circuit_evaliationShort_circuit_evaluation {
function a(a as boolean) {
=a
Line 2,413:
}
x=if(a(iv)->b(jv), F)
doc$<=format$("Calculating y x= a({0}) or b({1}) -> {2}", iv, jv, iv or jvx)+{
}+ format$("Calculating y = a({0}) or b({1}) -> {2}", iv, jv, iv or jv)+{
}
y=if(a(iv)->T, b(jv))
doc$<=format$("y={0}", y)+{
}
end while
Line 2,423 ⟶ 2,425:
report doc$
}
Short_circuit_evaluation
Short_circuit_evaliation
</syntaxhighlight>
{{out}}
Line 2,429 ⟶ 2,431:
Calculating x = a(False) and b(False) -> False
Called function a(False) -> False
x=False
Calculating y = a(False) or b(False) -> False
Called function a(False) -> False
Called function b(False) -> False
y=False
 
Calculating x = a(False) and b(True) -> False
Called function a(False) -> False
x=False
Calculating y = a(False) or b(True) -> True
Called function a(False) -> False
Called function b(True) -> True
y=True
 
Calculating x = a(True) and b(False) -> False
Called function a(True) -> True
Called function b(False) -> False
x=False
Calculating y = a(True) or b(False) -> True
Called function a(True) -> True
y=True
 
Calculating x = a(True) and b(True) -> True
Called function a(True) -> True
Called function b(True) -> True
x=True
Calculating y = a(True) or b(True) -> True
Called function a(True) -> True
y=True
 
</pre>
 
404

edits