Skip to content

Instantly share code, notes, and snippets.

@LH17
Created November 12, 2017 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LH17/cd178beac0266ac2dfbc704c7c9bbc1a to your computer and use it in GitHub Desktop.
Save LH17/cd178beac0266ac2dfbc704c7c9bbc1a to your computer and use it in GitHub Desktop.
precedencegroup IntersectionOperatorPrecedence {
associativity: left
}
infix operator ∩: IntersectionOperatorPrecedence
func ∩<T: Equatable> (left: [T], right: [T]) -> [T] {
var intersection: [T] = []
for value in left {
if right.contains(value) {
intersection.append(value)
}
}
return intersection
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment