4 ms·
That's a good one. It's one of the classic examples of the Unix philosophy and how pipelines can be powerful, although of course not applicable in all cases, an
by vram22 8y ago
That's a good one. It's one of the classic examples of the Unix philosophy and how pipelines can be powerful, although of course not applicable in all cases, and they have their issues too - which often becomes an argument on HN (about text streams vs. object pipes a la PowerShell, etc.).
I had seen it a while ago and blogged about it here, with solutions (approx.) in Python and shell:
The Bentley-Knuth problem and solutions:
https://jugad2.blogspot.com/2012/07/the-bentley-knuth-problem-and-solutions.html https://jugad2.blogspot.com/2012/07/the-bentley-knuth-proble...
Also, previous HN thread about it here:
Revisiting Knuth and McIlroy's word count programs (2011) (franklinchen.com)
https://news.ycombinator.com/item?id=15264997 https://news.ycombinator.com/item?id=15264997
- henrik_w 8y agoThere is also the book "Exercises in Programming Style" that uses the term frequency problem to illustrate 33 different programming paradigms (including a shell solution). https://www.amazon.com/Exercises-Programming-Style-Cristina-Videira/dp/1482227371/ https://www.amazon.com/Exercises-Programming-Style-Cristina-...
- vram22 8y agoCool. Will check that out.