Previous Up Next

6.4.6  Cartesian products

Defining an n-tuple.

To define an n-tuple (rather than a list of n objects), you can put the elements, separated by commas, inside the delimiters tuple[ and ]. For example:

set[tuple[1,3,4],tuple[1,3,5],tuple[2,3,4]]
     
tuple
1,3,4
,tuple
1,3,5
,tuple
2,3,4
          
The Cartesian product of two sets.

You can compute the Cartesian product of two sets with the infixed * operator. For example:

set[1,2]*set[3,4]
     
⟦ tuple[1,3], tuple[1,4], tuple[2,3], tuple[2,4] ⟧           
set[1,2]*set[3,4]*set[5,6]
     
⟦ tuple[1,3,5],tuple[1,3,6],tuple[1,4,5],tuple[1,4,6], tuple[2,3,5],tuple[2,3,6],tuple[2,4,5],tuple[2,4,6]⟧           

Previous Up Next