optional process
Paul Backus
snarwin at gmail.com
Thu Dec 5 15:43:30 UTC 2019
On Thursday, 5 December 2019 at 15:30:52 UTC, Taylor Hillegeist
wrote:
> On Friday, 29 November 2019 at 15:24:31 UTC, Paul Backus wrote:
>
>> .pipe!((output) {
>> if (sortOutput)
>> return output.sort!("a < b");
>> else
>> return output;
>> })
>> .writeln(); // maybe you meant each!writeln ?
>
> Why pipe as apposed to compose?
>
> Pipes functions in sequence. It offers the same functionality
> as compose, but with functions specified in reverse order. This
> may lead to more readable code in some situation because the
> order of execution is the same as lexical order.
>
> How does this not reverse the range?
range
.pipe!someFunction
.each!writeln;
is the same as
range
.someFunction
.each!writeln;
So why use pipe? Because in this case, the function we want to
apply is a lambda, and you can't call lambdas with UFCS.
More information about the Digitalmars-d-learn
mailing list