Short-circuit evaluation: Difference between revisions
Content added Content deleted
(Updates to work with Nim 1.4: added missing parameter types. Did also some formatting and added a general comment.) |
|||
Line 935: | Line 935: | ||
<lang dyalect>func a(v) { |
<lang dyalect>func a(v) { |
||
print(nameof(a), terminator |
print(nameof(a), terminator: "") |
||
return v |
return v |
||
} |
} |
||
func b(v) { |
func b(v) { |
||
print(nameof(b), terminator |
print(nameof(b), terminator: "") |
||
return v |
return v |
||
} |
} |
||
func test(i, j) { |
func test(i, j) { |
||
print("Testing a(\(i)) && b(\(j))") |
print("Testing a(\(i)) && b(\(j))") |
||
print("Trace: ", terminator |
print("Trace: ", terminator: "") |
||
print("\nResult: \(a(i) && b(j))") |
print("\nResult: \(a(i) && b(j))") |
||
print("Testing a(\(i)) || b(\(j))") |
print("Testing a(\(i)) || b(\(j))") |
||
print("Trace: ", terminator |
print("Trace: ", terminator: "") |
||
print("\nResult: \(a(i) || b(j))") |
print("\nResult: \(a(i) || b(j))") |
||
print() |
print() |
||
} |
} |
||
test(false, false) |
test(false, false) |
||
test(false, true) |
test(false, true) |