We have great support for input ranges and thus for the pull-based model of
programming, but the standard library offers almost nothing for the
push-based model :(  It utterly lacks tools for composing output ranges.

What I'd like to see working is this:

import std.stdio, std.algorithm, std.range;

void main() {
    auto printer = fork!(n => n % 2)(sink!(n => writeln("odd: ", n)),
                                                  sink!(n => writeln("even:
", n)))
        .filter!(n => n != 16)
        .map!(n => n * n);

    copy(iota(10), printer);
}

http://dpaste.dzfl.pl/612a8ad6

Reply via email to