Skip to content

Instantly share code, notes, and snippets.

@LH17
Created November 12, 2017 08:01
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/33b18f14b5773bbac42a0fe7f6c9562c to your computer and use it in GitHub Desktop.
Save LH17/33b18f14b5773bbac42a0fe7f6c9562c to your computer and use it in GitHub Desktop.
precedencegroup UnionOperatorPrecedence {
associativity: left
}
infix operator ∪: UnionOperatorPrecedence
func ∪ <T:Equatable>(lhs: [T], rhs:[T])->[T] {
var result = lhs
for element in rhs {
if !lhs.contains(element) {
result.append(element)
}
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment