Navigation
Synopsis Complement of a list relation.
Function
  1. lrel[&T0, &T1] complement(lrel[&T0, &T1] R)
  2. lrel[&T0, &T1, &T2] complement(lrel[&T0, &T1, &T2] R)
  3. lrel[&T0, &T1, &T2, &T3] complement(lrel[&T0, &T1, &T2, &T3] R)
  4. lrel[&T0, &T1, &T2, &T3, &T4] complement(lrel[&T0, &T1, &T2, &T3, &T4] R)
Usage import ListRelation;
Description Given a list 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 ListRelation;
ok
Declare R and compute corresponding U:
rascal>R = [<1,10>, <2, 20>, <3, 30>];
lrel[int,int]: [
  <1,10>,
  <2,20>,
  <3,30>
]
rascal>U = domain(R) * range(R);
lrel[int,int]: [
  <1,10>,
  <1,20>,
  <1,30>,
  <2,10>,
  <2,20>,
  <2,30>,
  <3,10>,
  <3,20>,
  <3,30>
]
Here is the complement of R computed in two ways:
rascal>U - R;
lrel[int,int]: [
  <1,20>,
  <1,30>,
  <2,10>,
  <2,30>,
  <3,10>,
  <3,20>
]
rascal>complement([<1,10>, <2, 20>, <3, 30>]);
lrel[int,int]: [
  <1,20>,
  <1,30>,
  <2,10>,
  <2,30>,
  <3,10>,
  <3,20>
]

Questions
Question [1].
The type of complement([<"K", 13>, <"Lime", -18>, <"Ginger", -9>]) is

Question [2].
complement([<"Kiwifruit", -9>, <"Forgetful Jones", 4>]) == 



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.