On 07/07/13 14:27, Peter Alexander wrote: > template allSatisfy(alias F, T...) > { > static if (T.length == 0) > { > enum allSatisfy = true; > } > else static if (T.length == 1) > { > enum allSatisfy = F!(T[0]); > } > else > { > enum allSatisfy = > allSatisfy!(F, T[ 0 .. $/2]) && > allSatisfy!(F, T[$/2 .. $ ]); > } > } > > Still looks like half-assed functional programming to me. > > Where's the iteration? Why can't I write this? > > template allSatisfy(alias F, T...) { > foreach(t; T) > if (!F!(t)) > return false; > return true; > } > > (Those are rhetorical questions btw, before anyone links me to a D tutorial).
template allSatisfy(alias F, T...) { enum allSatisfy = { foreach (E; T) if (!F!E) return false; return true; }(); } // And no, it isn't perfect. But not /that/ much is missing. // It's the more complex cases that would benefit from more meta features. artur