Brace expansion: Difference between revisions

Updated D entry
(Updated D entry)
Line 507:
 
Nullable!(Tuple!(string[], string)) getGroup(string s, in uint depth)
/*pure*/ nothrow @safe {
string[] sout;
auto comma = false;
Line 521:
sout ~= g;
 
if (s.front[0] == '}') {
if (comma)
return typeof(return)(tuple(sout, s[1 .. $]));
Line 536:
}
 
Tuple!(string[], string) getItems(string s, in uint depth=0) /*pure*/ @safe nothrow {
auto sout = [""];
 
Line 545:
 
if (c == "{") {
/*const*/ auto x = getGroup(s.dropOne, depth + 1);
if (!x.isNull) {
sout = cartesianProduct(sout, x[0])
Line 566:
}
 
void main() @safe {
immutable testCases = r"~/{Downloads,Pictures}/*.{jpg,gif,png}
It{{em,alic}iz,erat}e{d,}, please.