liveBook · Manning

Permutation map

As explained in Learn Haskell by Example

A permutation map is a mapping from a sorted word representation to the permutations of that word found in a word list.

A permutation map groups dictionary words by a key formed by sorting their letters. Words with the same sorted representation are stored together, so valid permutations can be retrieved without generating every possible rearrangement. section 5.3.2

The map specializes an associative map from String keys to lists of strings. Its operations sort the supplied key before delegating to the underlying map, keeping insertion, lookup, membership, alteration, and deletion consistent. section 5.3.2

Build a permutation map by:

Dictionary lookup

Given ["traces", "reacts", "crates", "caster", "tool", "loot", "cat"], the key "acerst" stores ["caster", "crates", "reacts", "traces"]. Looking up "reacts" returns that group, while looking up "tool" returns ["loot", "tool"]. section 5.3.3

A permutation map supports word-ladder construction by finding dictionary words formed after adding, removing, or changing letters. Sorting on lookup means the new letter can be added anywhere, and the removed letter need not be positionally tracked. section 5.4

How Learn Haskell by Example covers it

How deep it goes
Defines the representation, normalizes keys for map operations, constructs maps recursively, and stops short of permutation generation.
Examples
Uses an anagram-style dictionary sample containing traces, reacts, crates, caster, tool, loot, and cat.
What it assumes
Assumes associative-map operations and basic list processing while teaching sorted String keys through type inspection and implementation.
What you can do after
Build it from scratch by defining sorted-key operations and recursively inserting dictionary words into grouped lists.
How it connects
Connects associative maps, sorting, dictionary processing, lookup, and graph construction.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.