The D code part on the front page has only 2 examples currently. I thought we should add to that. As per the instructions, I'm posting one sample here for approval:

// Find anagrams of words
void main()
{
    import std.stdio, std.algorithm;
    string[][string] anagram_info;
    File("/usr/share/dict/words")
        .byLine
        .each!(w => anagram_info[w.dup.sort.idup] ~= w.idup);
    stdin
        .byLine
        .map!(l => anagram_info.get(l.sort.idup, []))
        .each!writeln;
}


PS: I'm new to writing idiomatic D, so there could be improvements to this example. Do point them out :)

Reply via email to