 
Navigation 
Synopsis Relation values.
Syntax
{ <Exp_{11}, Exp_{12}, ... > , <Exp_{21}, Exp_{22}, ... > , ... }
Types
Details CartesianProduct Composition FieldSelection Join ReflexiveTransitiveClosure Subscription TransitiveClosure
Description A relation is a set of elements with the following property:
rel[T_{1} L_{1}, T_{2} L_{2}, ... ] , where T_{1} , T_{2} , ... are arbitrary types and
L_{1} , L_{2} , ... are optional labels. It is a shorthand for set[tuple[T_{1} L_{1}, T_{2} L_{2}, ... ]] .
An nary relations with m tuples is denoted by {<E_{11}, E_{12}, ..., E_{1n}>,<E_{21}, E_{22}, ..., E_{2n}>, ..., <E_{m1}, E_{m2}, ..., E_{mn}>} ,
where the E_{ij} are expressions that yield the desired element type T_{i} .
Since relations are a form of set all operations (see Set) and functions (see Prelude/Set) are also applicable to relations. The following additional operators are provided for relations:
Examples
rascal>{<1,10>, <2,20>, <3,30>}
rel[int,int]: {
<3,30>,
<2,20>,
<1,10>
}
instead of rel[int,int] we can also give set[tuple[int,int]] as type of the above expression
remember that these types are interchangeable.
rascal>{<"a",10>, <"b",20>, <"c",30>} rel[str,int]: { <"c",30>, <"b",20>, <"a",10> } rascal>{<"a", 1, "b">, <"c", 2, "d">} rel[str,int,str]: { <"a",1,"b">, <"c",2,"d"> } Questions
Question [1].
A relation:
