anagram: Adopt functional style

As discussed in #79.

This also adds a test case to make sure that differently cased
versions of a word aren't recognized as anagrams. E.g. "the"
and "The" aren't anagrams.