Skip to content

Instantly share code, notes, and snippets.

@adamchalmers
Last active May 30, 2018 20:08
Show Gist options
  • Save adamchalmers/4e96256b440942b5e41cb16b725462d1 to your computer and use it in GitHub Desktop.
Save adamchalmers/4e96256b440942b5e41cb16b725462d1 to your computer and use it in GitHub Desktop.
func extend<T: Collection, U: Collection>(_ base: T, withNewElems: U) -> [T.Iterator.Element]
where T.Iterator.Element == U.Iterator.Element,
T.Iterator.Element: Equatable {
let newElems = withNewElems.filter { !base.contains($0) }
return Array(base) + newElems
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment