1

I am new to using D, and I wanted to ask for help on a simple method of breaking down a string into words. My program takes text from a file and is supposed to count the number of words in that text.

1 Answer 1

7

splitter and walkLength can do this trivially.

void main()
{
    import std.stdio, std.algorithm, std.range, std.file;
    writeln(readText("file.txt").splitter.walkLength());
}

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.