Page:Scheme - An interpreter for extended lambda calculus.djvu/11




 * 1) constant atoms, which match themselves only.
 * , which matches any single element in the expression consistently. We may abbreviate this as  by means of a LISP reader macro character.
 * , which matches any segment of zero or more elements in the expression consistently. We may abbreviate this as.

The matcher returns either, meaning no match is possible, or a list of two items, an alist specifying the bindings of the match variables, and a continuation to call, if you don't like this particular set of bindings, which will attempt to find another match. Thus, for example, the invocation

would return the result

where calling  as a function of no arguments would produce the result

where calling  would produce.

The  function makes use of two auxiliary functions called   and. The former returns a list of the first n elements of a given list, while the latter returns the tail of the given list after the first n elements.

The main  function also uses a subfunction called   which takes four arguments: the tail of the pattern yet to be matched; the tail of the expression yet to be matched; the alist of match bindings made so far; and a continuation to call if the match fails at this point. A subfunction of, called  , handles the matching of segments of the expression against   match variables. It is in the matching of segments that the