Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Set A with values 6,2,7
- val a = new NonEmpty(2, new NonEmpty(1, new Empty, new Empty), new NonEmpty(3, new Empty, new Empty))
- println("SET A")
- print("Set A contient 1: ")
- println(a contains 1)
- print("Set A contient 2: ")
- println(a contains 2)
- print("Set A contient 3: ")
- println(a contains 3)
- print("Set A contient 4: ")
- println(a contains 4)
- println("-----------")
- //Set B with values 6,1,7
- val b = new NonEmpty(2, new NonEmpty(1, new Empty, new Empty), new NonEmpty(4, new Empty, new Empty))
- println("SET B")
- print("Set B contient 1: ")
- println(b contains 1)
- print("Set B contient 2: ")
- println(b contains 2)
- print("Set B contient 3: ")
- println(b contains 3)
- print("Set B contient 4: ")
- println(b contains 4)
- println("-----------")
- //Set C: intersection of set A and set B
- val c = a.intersect(b);
- println("Set C: Intersection of SET A and SET B")
- print("Set C contient 1: ")
- println(c contains 1)
- print("Set C contient 2: ")
- println(c contains 2)
- print("Set C contient 3: ")
- println(c contains 3)
- print("Set C contient 4: ")
- println(c contains 4)
- println("-----------")
- //Set D: even numbers of set A
- val d = b.filter(x => (x%2 == 0))
- println("SET D: filter of even number of set B:")
- print("Set D contient 1: ")
- println(d contains 1)
- print("Set D contient 2: ")
- println(d contains 2)
- print("Set D contient 3: ")
- println(d contains 3)
- print("Set D contient 4: ")
- println(d contains 4)
- println("-----------")
- //Set E: intersection of Set A and set B using the second way to compute the intersection
- val e = a.intersect2(b)
- println("SET E: Intersection of set A and set B using the second method")
- print("Set E contient 1: ")
- println(e contains 1)
- print("Set E contient 2: ")
- println(e contains 2)
- print("Set E contient 3: ")
- println(e contains 3)
- print("Set E contient 4: ")
- println(e contains 4)
- println("-----------")
Add Comment
Please, Sign In to add comment