Rules for Pattern Matching

Pattern matching can be thought of as a special kind of equality test:

  1. Function names, constants and structure in the pattern must be matched exactly by the input.

  2. A variable in the pattern will match anything in the input, but it must do so consistently.

    We implement this by letting a variable match anything the first time, but it can only match the same thing thereafter.

Contents    Page-10    Prev    Next    Page+10    Index