Range-Based Graph Search in D (blog post)

bearophile bearophileHUGS at lycos.com
Thu Jan 9 14:54:10 PST 2014


Peter Alexander:

> http://poita.org/2014/01/09/range-based-graph-search-in-d.html

I'd like to see the usage of a not implicit graph.

Regarding this line:

static d(string a, string b) { return zip(a, b).count!"a[0] != 
a[1]"; }

An alternative:

enum dist = (in string s, in string s2) pure =>
     s1.zip(s2).count!(ab => ab[0] != ab[1]);

It's a use case for some tuple unpacking syntax:

enum dist = (in string s1, in string s2) pure =>
     s1.zip(s2).count!(@{a, b} => a != b);

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list