RosettaCodeData/Task/Short-circuit-evaluation/Sidef/short-circuit-evaluation.sidef
2016-12-05 23:44:36 +01:00

16 lines
353 B
Text
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

func a(bool) { print 'A'; return bool }
func b(bool) { print 'B'; return bool }
 
# Test-driver
func test() {
for op in ['&&', '||'] {
for x,y in [[1,1],[1,0],[0,1],[0,0]] {
"a(%s) %s b(%s): ".printf(x, op, y)
eval "a(Bool(x)) #{op} b(Bool(y))"
print "\n"
}
}
}
 
# Test and display
test()