λ

2.0: Pattern matching

Standard ML allow you to pattern match on values, providing case anaylsis. Using the list built into Standard ML, we could pattern match on its cases and apply a function to each value in the list.

It’s possible to pattern match directly in the function definition and avoid the intermediate values to make it less verbose, as in map'.

(* examples/pattern-matching.sml *)