Skip to content

Instantly share code, notes, and snippets.

@jonfriskics
Created June 2, 2014 21:27
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 jonfriskics/42620923a79b87017468 to your computer and use it in GitHub Desktop.
Save jonfriskics/42620923a79b87017468 to your computer and use it in GitHub Desktop.
func anyCommonElements <T, U where T: Sequence, U: Sequence, T.GeneratorType.Element: Equatable, T.GeneratorType.Element == U.GeneratorType.Element> (lhs: T, rhs: U) -> Bool {
for lhsItem in lhs {
for rhsItem in rhs {
if lhsItem == rhsItem {
return true
}
}
}
return false
}
anyCommonElements([1, 2, 3], [3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment