Skip to content

Instantly share code, notes, and snippets.

@giginet
Created August 19, 2018 02:02
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 giginet/eb6eb4958d6c69f4d49ac6c5d4b9eabf to your computer and use it in GitHub Desktop.
Save giginet/eb6eb4958d6c69f4d49ac6c5d4b9eabf to your computer and use it in GitHub Desktop.
private func consistsOfSameElements<Element: Equatable>(between lhs: [Element], and rhs: [Element]) -> Bool {
let contained = lhs.compactMap { element in
return rhs.contains(element) ? element : nil
}
return contained == lhs
}
private func contains<Element: Equatable>(_ element: [Element], in collection: [[Element]]) -> Bool {
return collection.contains { consistsOfSameElements(between: element, and: $0) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment