RosettaCodeData/Task/Short-circuit-evaluation/Nanoquery/short-circuit-evaluation.nanoquery
2023-07-01 13:44:08 -04:00

47 lines
935 B
Text

def short_and(bool1, bool2)
global a
global b
if a(bool1)
if b(bool2)
return true
else
return false
end
else
return false
end
end
def short_or(bool1, bool2)
if a(bool1)
return true
else
if b(bool2)
return true
else
return false
end
end
end
def a(bool)
println "a called."
return bool
end
def b(bool)
println "b called."
return bool
end
println "F and F = " + short_and(false, false) + "\n"
println "F or F = " + short_or(false, false) + "\n"
println "F and T = " + short_and(false, true) + "\n"
println "F or T = " + short_or(false, true) + "\n"
println "T and F = " + short_and(true, false) + "\n"
println "T or F = " + short_or(true, false) + "\n"
println "T and T = " + short_and(true, true) + "\n"
println "T or T = " + short_or(true, true) + "\n"