Lesson 2: Case expressions practice

  • The goal
  • The anagram checker
  • Word validator
  • Validate first, then compare
  • Interactive program
  • 14 minutes

This lesson presents an extended example of using case expressions. In particular, we look carefully at an example that pattern matches on Maybe values, since the rest of the course assumes you understand that well. Our example code checks two String inputs to see if they are anagrams of one another. Additionally, we write a main executable that asks for and accepts user inputs in the REPL and uses the anagram-checking function on those inputs.

Sign up for access to the full page, plus the complete archive and all the latest content.