Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
13
Task/Catamorphism/D/catamorphism.d
Normal file
13
Task/Catamorphism/D/catamorphism.d
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
void main() {
|
||||
import std.stdio, std.algorithm, std.range, std.meta, std.numeric,
|
||||
std.conv, std.typecons;
|
||||
|
||||
auto list = iota(1, 11);
|
||||
alias ops = AliasSeq!(q{a + b}, q{a * b}, min, max, gcd);
|
||||
|
||||
foreach (op; ops)
|
||||
writeln(op.stringof, ": ", list.reduce!op);
|
||||
|
||||
// std.algorithm.reduce supports multiple functions in parallel:
|
||||
reduce!(ops[0], ops[3], text)(tuple(0, 0.0, ""), list).writeln;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue