예제 #1
0
 public function testUnion()
 {
     $set1 = new Set(array(1, 2, 3));
     $set2 = new Set(array(2, 3, 4));
     $set3 = $set1->union($set2);
     $arr = array(1, 2, 3, 4);
     foreach ($arr as $n) {
         self::assertTrue($set3->member($n));
     }
 }
예제 #2
0
파일: Set.php 프로젝트: inbarzecharia/Ruler
 /**
  * Set symmetric difference operator.
  *
  * Returns a Set which is the symmetric difference of this Set with the
  * passed Set.
  *
  * @param Value $set
  *
  * @return Set
  */
 public function symmetricDifference(Value $set)
 {
     $returnValue = new Set(array());
     return $returnValue->union($this->complement($set), $set->getSet()->complement($this));
 }
예제 #3
0
 /**
  * Axiom: (A ∪ B) × C = (A × C) ∪ (B × C)
  * A union B cross C is the union of A cross C and B cross C
  * @dataProvider dataProviderForThreeSets
  */
 public function testAUnsionBCrossCEqualsUnsionOfACRossCAndBCrossC(Set $A, Set $B, Set $C)
 {
     $⟮A∪B⟯×C = $A->union($B)->cartesianProduct($C);
     $⟮A×C⟯∪⟮B×C⟯ = $A->cartesianProduct($C)->union($B->cartesianProduct($C));
     $this->assertEquals($⟮A∪B⟯×C, $⟮A×C⟯∪⟮B×C⟯);
     $this->assertEquals($⟮A∪B⟯×C->asArray(), $⟮A×C⟯∪⟮B×C⟯->asArray());
 }
예제 #4
0
 public static function successor($x)
 {
     return Set::union($x, Set::singleton($x));
 }