On Mon, 2019-06-10 at 08:02 +0000, vitalfadeev via Digitalmars-d-learn wrote:
[…]
Perhaps I am missing something that is critical to the example, but I
rewrote the code as:
import std.algorithm: map;
import std.stdio: writeln;
bool false_cb() { return false; }
bool true_cb() { return true; }
void main() {
auto checkers = [&false_cb, &false_cb, &true_cb];
auto result = map!(a => a())(checkers);
writeln(result);
}
This avoids the assumption that 0 is false and 1 is true. Also it makes
use of D map which seems to me what is happening at the core of the
code – using foreach and zip or lockstep just seems to be implementing
map. But as I say, I may be missing something.
--
Russel.
===========================================
Dr Russel Winder t: +44 20 7585 2200
41 Buckmaster Road m: +44 7770 465 077
London SW11 1EN, UK w: www.russel.org.uk
signature.asc
Description: This is a digitally signed message part
