wc in D: 712 Characters Without a Single Branch

Paul Backus snarwin at gmail.com
Tue Jan 28 17:07:40 UTC 2020


On Tuesday, 28 January 2020 at 14:01:35 UTC, Mike Parker wrote:
> Robert Schadek was inspired by a post he saw on Hacker News a 
> while back showing an implementation of wc in Haskell totaling 
> 80 lines. He decided he could do better in D. So he did. This 
> post on the D blog shows what he came up with and also provides 
> a brief introduction to ranges.
>
>
> The blog:
> https://dlang.org/blog/2020/01/28/wc-in-d-712-characters-without-a-single-branch/

> unittest {
> 	foreach(it; Iota(1,10).Filter(&isEven)) {
> 		writeln(it);
> 	}
> }

Today I learned you can use UFCS with struct 
literals/constructors.


More information about the Digitalmars-d-announce mailing list