I really do need a set for the next part of the program, but taking your code and ideas I have now reduced the function to this:

WordSet getWords(string filename, int wordsize) {
    WordSet words;
        .map!(line => line.until!(not!isAlpha))
        .filter!(word => word.count == wordsize)
        .each!(word => words[word.to!string.toUpper] = 0);
    return words;

This is also 4x faster than my version that used a regex -- thanks!

Why did you use string.count rather than string.length?

Reply via email to