[your code here]
Saurabh Das via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jan 10 20:36:04 PST 2016
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 :)
More information about the Digitalmars-d
mailing list