![]() |
|
Navigation |
Synopsis Complement of a relation.
Function
Usage
import Relation;
Description Given a relation
R a new relation U can be constructed that contains
all possible tuples with element values that occur at corresponding tuple positions in R .
The function complement returns the complement of R relative to U , in other words: U - R .
Examples
rascal>import Relation;
ok
Declare R and compute corresponding U :
rascal>R = {<1,10>, <2, 20>, <3, 30>}; rel[int,int]: { <3,30>, <2,20>, <1,10> } rascal>U = domain(R) * range(R); rel[int,int]: { <3,30>, <2,30>, <1,30>, <1,20>, <3,20>, <2,20>, <3,10>, <2,10>, <1,10> }Here is the complement of R computed in two ways:
rascal>U - R; rel[int,int]: { <2,30>, <1,30>, <1,20>, <3,20>, <3,10>, <2,10> } rascal>complement({<1,10>, <2, 20>, <3, 30>}); rel[int,int]: { <2,30>, <1,30>, <1,20>, <3,20>, <3,10>, <2,10> } Questions
Question [1].
![]() ![]()
Question [2].
![]() ![]() ![]() |