Created
November 12, 2017 08:03
-
-
Save LH17/cd178beac0266ac2dfbc704c7c9bbc1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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