![]() |
| ||||||||
Navigation |
Synopsis ListRelation values.
Syntax
[ <Exp11, Exp12, ... > , <Exp21, Exp22, ... > , ... ]
Types
Details CartesianProduct Composition FieldSelection Join ReflexiveTransitiveClosure Subscription TransitiveClosure
Description A list relation is a list of elements with the following property:
lrel[T1 L1, T2 L2, ... ] , where T1 , T2 , ... are arbitrary types and
L1 , L2 , ... are optional labels. It is a shorthand for list[tuple[T1 L1, T2 L2, ... ]] .
An n-ary list relation with m tuples is denoted by [<E11, E12, ..., E1n>,<E21, E22, ..., E2n>, ..., <Em1, Em2, ..., Emn>] ,
where the Eij are expressions that yield the desired element type Ti .
Since list relations are a form of list all operations (see List) and functions (see Prelude/List) are also applicable to relations. The following additional operators are provided for list relations:
Examples
rascal>[<1,10>, <2,20>, <3,30>]
lrel[int,int]: [
<1,10>,
<2,20>,
<3,30>
]
instead of lrel[int,int] we can also give list[tuple[int,int]] as type of the above expression
remember that these types are interchangeable.
rascal>[<"a",10>, <"b",20>, <"c",30>] lrel[str,int]: [ <"a",10>, <"b",20>, <"c",30> ] rascal>[<"a", 1, "b">, <"c", 2, "d">] lrel[str,int,str]: [ <"a",1,"b">, <"c",2,"d"> ] Questions
Question [1].
![]() ![]() ![]() |