d绑定函数

最新加的,std.functional.bind

a.byPair.map!(bind!((k, v) => format!"%s=%s"(k, v))).writeln;
auto gcds = cartesianProduct(r,r).map!(bind!gcd);

扩展当前的map:

auto map(alias fun, R)(R range) {
    static if (arity!fun == 1) {
        ... // 当前实现
    } else {
        ... // 用.tupleof来扩展.
            // 也可检查.tupleof.length匹配arity!fun.
    }
}
posted @ 2022-07-06 08:46  zjh6  阅读(11)  评论(0)    收藏  举报  来源