Reading a file of words line by line
dwdv
dwdv at posteo.de
Thu Jan 16 10:10:02 UTC 2020
On 2020-01-16 04:54, Jesse Phillips via Digitalmars-d-learn wrote:
> [...]
> .map!(word => word.to!string.toUpper)
> .array
> .sort
> .uniq
> .map!(x => tuple (x, 0))
> .assocArray ;
>
.each!(word => words[word.to!string.toUpper] = 0);
isn't far off, but could also be (sans imports):
return File(filename).byLine
.map!(line => line.until!(not!isAlpha))
.filter!(word => word.count == wordsize)
.map!(word => word.to!string.toUpper)
.assocArray(0.repeat);
More information about the Digitalmars-d-learn
mailing list