Guest User

Untitled

a guest
Apr 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. # define a set
  2. $x = [System.Collections.Generic.HashSet[string]]::new()
  3. 'python'.ToCharArray().foreach({[void]$x.add($_)})
  4.  
  5. $y = [System.Collections.Generic.HashSet[string]]::new()
  6. 'powershell'.ToCharArray().foreach({[void$y.add($_)})
  7.  
  8. $x.ExceptWith($y) # All the elements in x but not in y
  9. # union
  10. $x.UnionWith($y) # Unique elements in x or y or both
  11. # intersection
  12. $x.IntersectWith($y) # Elements in both x and y
  13. $x.SymmetricExceptWith($y) # Elements in x or y but not in both
Add Comment
Please, Sign In to add comment