On 11/25/05, Benjamin L. Russell <[EMAIL PROTECTED]> wrote: > Specifically, when pattern-matching a list of Xs into, > say, (X|Xr), how does Oz know that X denotes the car, > and Xr denotes the cdr of the list (to borrow Scheme > terminology)?
The unification algorithm requires it. A list is a set of '|' tuples, right? That is, instead of representing the list [a b c] as cons(a, cons(b, cons(c, nil))) it is represented as a record with '|' as the label: '|'(a '|'(b '|'(c nil))). Matching this list against X|Foo, which itself is '|'(X Foo), requires that X=a and Foo='|'(b '|'(c nil)). The variable names, as you can see, are not significant. In your pattern-matching example using #s, matching Xs#Ys against X|Xr#Y|Yr comes out basically the same way. The outer-level #s match against each other, and X must have the structure '|'(X Xr) and Y must have the structure '|'(Y Yr), which effectively means X=car and Xr=cdr. Max Wilson -- Be pretty if you are, Be witty if you can, But be cheerful if it kills you. _________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
