1#2#3 is a single tuple of three elements?

Yves Jaradin yves.jaradin at uclouvain.be
Wed Nov 21 14:05:46 CET 2007


Terrence Brannon wrote:

>Re: http://www.mozart-oz.org/documentation/tutorial/node3.html#chapter.basics
>
>I've been staring at this sentence for 10 minutes, trying to simply
>accept what it says, but it just does not make any sense to me:
>
>   observe that 1#2#3 is a single tuple of three elements
>
>But to my way of thinking, # is a binary operator and regardless of
>associativity, it first creates a 2-tuple of two values and then
>another 2-tuple nesting the first 2-tuple and the remaining element.
>
>I really dont see how # could operate any other way, but would
>appreciate any feedback on how this is possible.
>_________________________________________________________________________________
>mozart-users mailing list                               mozart-users at mozart-oz.org
>http://www.mozart-oz.org/mailman/listinfo/mozart-users
>  
>
The simple explanation is that # isn't a binary operator. It is an n-ary 
operator that creates a tuple of n elements. However, it's most commonly 
used to build pairs where it looks like a binary operator.

In other words,
A#B#C \= (A#B)#C
A#B#C \= A#(B#C)

A#B#C= '#'(A B C)
(A#B)#C = '#'('#'(A B) C)
A#(B#C) = '#'(A '#'(B C))

A#B#C#D = '#'(A B C D)

Cheers,
Yves


More information about the mozart-users mailing list