Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Extend-your-language/D/extend-your-language.d
Normal file
32
Task/Extend-your-language/D/extend-your-language.d
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
void if2(T1, T2, T3, T4)(in bool c1, in bool c2,
|
||||
lazy T1 first,
|
||||
lazy T2 both,
|
||||
lazy T3 second,
|
||||
lazy T4 none) {
|
||||
if (c1) {
|
||||
if (c2)
|
||||
both;
|
||||
else
|
||||
first;
|
||||
} else {
|
||||
if (c2)
|
||||
second;
|
||||
else
|
||||
none;
|
||||
}
|
||||
}
|
||||
|
||||
void test(in bool a, in bool b) {
|
||||
import std.stdio;
|
||||
if2(a, b, writeln("first"),
|
||||
writeln("both"),
|
||||
writeln("second"),
|
||||
writeln("none"));
|
||||
}
|
||||
|
||||
void main() {
|
||||
test(1 < 2, 3 > 4);
|
||||
test(1 < 2, 1 < 2);
|
||||
test(3 > 4, 3 > 4);
|
||||
test(3 > 4, 1 < 2);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue