Knuth and McIlroy’s Word Count Programs – Java 8 Version

Franklin Chen wrote an interesting article about how Donald Knuth was asked to write a word count program using literate programming and how Doug McIlroy wrote an equivalent one-liner using the Unix shell. Franklin then goes on to rewrite the program in Haskell. As an exercise I have written my own version of the program using Java 8 lambdas and streams. The guts of the program is a (long) one-liner. Here is my version: It’s not as straightforward as the shell version, but still a nice example of the power of the new Java 8 features.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s