Navigation
Synopsis Complement of a relation.
Function
  1. rel[&T0, &T1] complement(rel[&T0, &T1] R)
  2. rel[&T0, &T1, &T2] complement(rel[&T0, &T1, &T2] R)
  3. rel[&T0, &T1, &T2, &T3] complement(rel[&T0, &T1, &T2, &T3] R)
  4. rel[&T0, &T1, &T2, &T3, &T4] complement(rel[&T0, &T1, &T2, &T3, &T4] R)
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].
The type of complement({<"Sy Snootles", 13>, <"Elmo", 17>}) is

Question [2].
complement({<"Joh Yowza", 9>, <"Pumpkin", 13>, <"Count Von Count", 14>}) == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.