Reading a file of words line by line
dwdv
dwdv at posteo.de
Wed Jan 15 18:16:02 UTC 2020
On 2020-01-15 16:34, mark via Digitalmars-d-learn wrote:
> Is this as compact as it _reasonably_ can be?
How about this?
auto uniqueWords(string filename, uint wordsize) {
import std.algorithm, std.array, std.conv, std.functional, std.uni;
return File(filename).byLine
.map!(line => line.until!(not!isAlpha))
.filter!(word => word.count == wordsize)
.map!(word => word.to!string.toUpper)
.array
.sort
.uniq;
}
More information about the Digitalmars-d-learn
mailing list