optional process
Paul Backus
snarwin at gmail.com
Fri Nov 29 15:24:31 UTC 2019
On Friday, 29 November 2019 at 15:17:35 UTC, Taylor R Hillegeist
wrote:
> I know phobos has choose which is close.
> But what I want is something like:
>
> bool sortOutput;
>
> if(sortOutput){
> read(Textfile)
> .splitter("\n")
> .filter(a=>a.contains("data))
> .doif(sortOutput,sort!("a < b"))
> .writeln();
import std.functional: pipe;
bool sortOutput;
read(Textfile)
.splitter("\n")
.filter!(a=>a.contains("data))
.pipe!((output) {
if (sortOutput)
return output.sort!("a < b");
else
return output;
})
.writeln(); // maybe you meant each!writeln ?
More information about the Digitalmars-d-learn
mailing list