Okay, I've yet to make this work in Scheme form, but I've got an idea for a linear logarithmic time algorithm that might actually suit this use well. I will share, and you guys tell me if you see any obvious holes in my thinking. (This is a nasty one to get right and make run quickly, MB...curse you!)
Essentially, we'd need to map the entire alphabet to prime numbers. (a = 2, b = 3, c = 5, d = 7, e = 11)
per
http://primes.utm.edu/lists/small/1000.txt.
Now, all words can be added together to create a 'anagram value'. "cab = 10", for instance. I'm pretty sure that only "anagram true" words will have the same value in this case. Now, Machine("I like watching you suffer")Bacon, has asked that we only print results that are somewhere in our system. Instead of having to run a hash on every single possibility of of every word (which will probably be an overflow in Clojure, and an insanely long run time in Chicken)...we can simply determine values of all of the filenames that we wish to check against. As soon as we have a value match, we can be sure that it's an anagram, print its value, and continue down through the file structure. This is not recursive, so while there's a lot of work on the front end, the back end should be very fast.
My (lack of) knowledge of Scheme is what's killing me here, but I'm still working on it.
We would also need to determine if the word to be checked has the same length as our hashed word, as (ab == c) by value alone. This should probably be step 1, and discard the word if it isn't the same length first. Quick check should go first, IMHO.