Brace expansion: Difference between revisions

Content added Content deleted
(→‎{{header|Java}}: small changes)
(Updated D entry)
Line 504:
{{trans|Python}}
This code is not UTF-corrected, because it uses slicing instead of front, popFront, etc.
<lang d>import std.stdio, std.typecons, std.array, std.range, std.algorithm, std.string;
std.string;
 
Nullable!(Tuple!(string[], string)) getGroup(string s, in uint depth) {
/*pure*/ @safe {
string[] sout;
auto comma = false;
 
while (!s.empty) {
// ({const g, s)} = getItems(s, depth);
const r = getItems(s, depth);
const g = r[0];
Line 536:
}
 
Tuple!(string[], string) getItems(string s, in uint depth=0) /*pure*/ @safe {
auto sout = [""];
 
Line 547:
const x = getGroup(s.dropOne, depth + 1);
if (!x.isNull) {
//sout = cartesianProduct(sout), x[0])
string .map!(ab => ab[0] outTmp;~ ab[1])
foreach (const a; sout) .array;
foreach (const b; x[0])
outTmp ~= a ~ b;
sout = outTmp;
s = x[1];
continue;