-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
67 lines (29 loc) · 1.27 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
- EXAMPLES -
# Create some sets. Parameters are label and universe (both optional).
$set1 = new Set("Guy's names", "People");
$set1->add(array("Pat", "Lauren", "Matt", "Joe", "Billy"));
$set2 = new Set("Girl's names", "People");
$set2->add(array("Christy", "Pat", "Lauren", "Joe", "Kelly", "Tamara"));
$set3 = new Set("Celebs", "People");
$set3->add("Christy", "Kelly", "Matt", "Joe", "Brad", "Miley");
$set4 = new Set("Positive #s", "Rational #s");
$set4->add(range(1, 10));
$set5 = new Set("Copy", "Rational #s");
$set5->add($set4)->add(11, 12, 13, 14, 15);
# Perform set operations. All set operations return a 'result' set except isSubset() and isSuperset().
$resultSet = $set1->union($set2, $set3);
echo $resultSet->getLabel();
var_dump($resultSet->get());
$resultSet = $set1->symDiff($set2, $set3);
echo $resultSet->getLabel();
var_dump($resultSet->get());
$resultSet = $set1->relComp($set2, $set3);
echo $resultSet->getLabel();
var_dump($resultSet->get());
$resultSet = $set1->intersection($set2, $set3);
echo $resultSet;
var_dump($resultSet->get());
echo $set4->isSubset($set5);
echo $set5->isSuperset($set4);
# The following will throw a 'Set_Exception' exception because the two sets do not belong to the same universe
$resultSet = $set1->union($set4);