Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Comma-quibbling/D/comma-quibbling-1.d
Normal file
17
Task/Comma-quibbling/D/comma-quibbling-1.d
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import std.stdio, std.string;
|
||||
|
||||
string quibbler(in string[] seq) pure /*nothrow*/ {
|
||||
if (seq.length <= 1)
|
||||
return format("{%-(%s, %)}", seq);
|
||||
else
|
||||
return format("{%-(%s, %) and %s}", seq[0 .. $-1], seq[$-1]);
|
||||
}
|
||||
|
||||
void main() {
|
||||
//foreach (immutable test; [[],
|
||||
foreach (const test; [[],
|
||||
["ABC"],
|
||||
["ABC", "DEF"],
|
||||
["ABC", "DEF", "G", "H"]])
|
||||
test.quibbler.writeln;
|
||||
}
|
||||
10
Task/Comma-quibbling/D/comma-quibbling-2.d
Normal file
10
Task/Comma-quibbling/D/comma-quibbling-2.d
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import std.stdio, std.string, std.algorithm, std.conv, std.array;
|
||||
|
||||
enum quibbler = (in string[] a) pure =>
|
||||
"{%-(%s and %)}".format(a.length < 2 ? a :
|
||||
[a[0 .. $-1].join(", "), a.back]);
|
||||
|
||||
void main() {
|
||||
[[], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"]]
|
||||
.map!quibbler.writeln;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue