Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Created April 12, 2018 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save PrateekKumarSingh/7c2ab9b177255bcad038242562d7423f to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/7c2ab9b177255bcad038242562d7423f to your computer and use it in GitHub Desktop.
# define a set
$x = [System.Collections.Generic.HashSet[string]]::new()
'python'.ToCharArray().foreach({[void]$x.add($_)})
$y = [System.Collections.Generic.HashSet[string]]::new()
'powershell'.ToCharArray().foreach({[void$y.add($_)})
$x.ExceptWith($y) # All the elements in x but not in y
# union
$x.UnionWith($y) # Unique elements in x or y or both
# intersection
$x.IntersectWith($y) # Elements in both x and y
$x.SymmetricExceptWith($y) # Elements in x or y but not in both
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment