Divide & Conquer divides, but doesn't conquer
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon May 25 01:48:38 UTC 2020
Another one:
template Filter(alias pred, TList...)
{
static if (TList.length == 0)
{
alias Filter = AliasSeq!();
}
else static if (TList.length == 1)
{
static if (pred!(TList[0]))
alias Filter = AliasSeq!(TList[0]);
else
alias Filter = AliasSeq!();
}
else
{
alias Filter =
AliasSeq!(
Filter!(pred, TList[ 0 .. $/2]),
Filter!(pred, TList[$/2 .. $ ]));
}
}
Why cut the problem size in half if it doesn't improve complexity?
More information about the Digitalmars-d
mailing list