Sample programs
Now that we have taken a detailed look at the core functional programming constructs, it's time to indulge in power play (with code of course). Let's learn to play the game with some hardcore sample programs.
Spell checker
This was inspired by Peter Norvig's (former Research Director at Google) technical blog on How to Write a Spelling Corrector. What is interesting is the way the solution has been envisaged. The solution employs the probability theory at its core to find all possible corrections for a word of length n, by accounting for user errors in the form of typos arising because of omissions (deletes), characters misplaced (replaces and transposes), and inserted (inserts).
You can refer to this technical blog on How to Write a Spelling Corrector by Peter Norvig for the following:
Note
For a word of length n, there will be n deletions, n-1 transpositions, 26n replacements, and 26(n+1) insertions.
To have fair shot at determining the corrections, we do find all possible corrections...