-*- org -*-
A grab bag of ideas that are applicable to all the implementations, but probably appear only in some.
Rather than listing all the anagrams, instead just list the words that can be made from the bag, and next to each word, provide a thunk which will generate the remaining anagrams. This should save a lot of time if you’re just looking for funny anagrams – you’ll get a list of perhaps 100 words that can be made from the bag; you’ll choose one, the thunk will run, and you start over.
This isn’t necessarily better than any other method for all implementations, but it seems the best for Perl 5, since it can be used as a hash key (convenient when reading the dictionary). And anyway, subtracting two such things ought to be fast, assuming that substr is fast.
And yet I tried this first when writing the C++ version. It worked OK, but I then tried using bignums … and they were twice as fast. Hmm.
Many (especially those I’ve touched recently) use the dictionary in this directory, but some (C++ in particular) still look for /usr/share/dict/words, which of course won’t work on Windows.
Apply the sorting optimization that I did in 8f9c80574c55933440e972d7c6af21859aa7c06b to other implementations.
This is probably much harder than it should be, because I really mean “write one program which will work in all the scheme implementations”. Writing portable Scheme is hard (and, as I repeatedly proclaim on IRC, not worth the effort). Let’s go shopping.
They’re practically the same, except the former draws stuff in a window, whereas the latter just returns a list of stuff.
Suggested by Kevin-from-Seajure.