UFCS and overloading
cym13 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 7 07:46:51 PDT 2015
EDIT: mis-formatted previous snippet
import std.algorithm, std.stdio, std.range, std.conv;
void main()
{
stdin
.byLine
.filter!(s => !s.empty && s.front != '#’) // Filter with
this lambda function
.map!(s => s.to!double) // Map the strings to doubles
.array // Sorting needs random access
.sort!((a, b) => a < b) // Another lambda
.take(10) // Applyable to any range
.writeln;
}
More information about the Digitalmars-d-learn
mailing list