Matching simple patterns is very useful, but there's more that we can do. Patterns can be more complex, consisting of representations of several layers of nested data structures and other data types. Patterns can assign to a variable name while still looking deeper into the structure to make sure the contained information matches what we want. Or patterns can be simplified, checking only a few parts of the data structure and ignoring the rest.
Matching tuples and other more complex patterns
Nested patterns
We can use pattern matching to pull a value out of a complex data structure. As long as the pattern matches the data value, it doesn't matter how complex the pattern and value are. If we want to match a tuple of...