Monday, July 29, 2013

Intersect Lists and Maps

List a = [1,2,3]
List b = [2,3,4]
assert [2,3] == a.intersect(b)
assert [1,2,3,4] == (a + b).unique()
assert [1] == a - b
assert [4] == b - a


Map c = [a:1, b:2, c:44]
Map d = [b:2, c:3]
assert [b:2] == c.intersect(d)
assert [a:1, b:2, c:3] == c + d
assert [a:1, b:2, c:44] == d + c
assert [a:1, c:44] == c - d
assert [c:3] == d - c

No comments:

Post a Comment