all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
21
Task/Short-circuit-evaluation/D/short-circuit-evaluation.d
Normal file
21
Task/Short-circuit-evaluation/D/short-circuit-evaluation.d
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import std.stdio, std.algorithm;
|
||||
|
||||
T a(T)(T answer) {
|
||||
writefln(" # Called function a(%s) -> %s", answer, answer);
|
||||
return answer;
|
||||
}
|
||||
|
||||
T b(T)(T answer) {
|
||||
writefln(" # Called function b(%s) -> %s", answer, answer);
|
||||
return answer;
|
||||
}
|
||||
|
||||
void main() {
|
||||
foreach (immutable x, immutable y;
|
||||
[false, true].cartesianProduct([false, true])) {
|
||||
writeln("\nCalculating: r1 = a(x) && b(y)");
|
||||
immutable r1 = a(x) && b(y);
|
||||
writeln("Calculating: r2 = a(x) || b(y)");
|
||||
immutable r2 = a(x) || b(y);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue