[Issue 9882] Add UFCS-friendly printing functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 26 15:28:40 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9882



--- Comment #6 from bearophile_hugs at eml.cc 2013-04-26 15:28:37 PDT ---
A suggestion in D.learn shows me that sometimes
std.functional.binaryReverseArgs is an acceptable solution for the terminal
writefln (but it can't be used for intermediate printing):


import std.stdio: writeln, writefln;
import std.range: iota, transversal;
import std.algorithm: map, reduce, max;
import std.functional: binaryReverseArgs;

void main() {
    immutable txt = ["Line one", "Line 2"];

    txt
    .map!q{ a.length }
    .map!((s){ s.writeln; return s; })
    .reduce!max
    .iota
    .map!(i => txt.transversal(i))
    .binaryReverseArgs!writefln("%(%s\n%)");
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list