On 26.11.2005, at 08:47, Russ Abbott wrote:
In scheme (cons 'a '(b c)) yields (a b c), which is a . (b c).

(cons 'a '(b c)) in Scheme's dotted pair notation is

(a . (b . (c . nil)))

The last tail is () or nil (as in Oz). A list whose last tail is not nil is called an improper list in Scheme. Note that an improper list is not a list. (quoting from the Scheme reference www.swiss.csail.mit.edu/~jaffer/r5rs_toc.html)

Best,
Torsten



 


On 11/25/05, Maximilian Wilson <[EMAIL PROTECTED]> wrote: 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


_______________________________________________________________________ __________ mozart-users mailing list [email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

--
Torsten Anders
Sonic Arts Research Centre
Queen's University Belfast (UK)
www.torsten-anders.de


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to