RosettaCodeData/Task/Short-circuit-evaluation/Standard-ML/short-circuit-evaluation.ml
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

22 lines
581 B
Standard ML

fun a r = ( print " > function a called\n"; r )
fun b r = ( print " > function b called\n"; r )
fun test_and b1 b2 = (
print ("# testing (" ^ Bool.toString b1 ^ " andalso " ^ Bool.toString b2 ^ ")\n");
ignore (a b1 andalso b b2) )
fun test_or b1 b2 = (
print ("# testing (" ^ Bool.toString b1 ^ " orelse " ^ Bool.toString b2 ^ ")\n");
ignore (a b1 orelse b b2) )
fun test_this test = (
test true true;
test true false;
test false true;
test false false )
;
print "==== Testing and ====\n";
test_this test_and;
print "==== Testing or ====\n";
test_this test_or;