Skip to content

Instantly share code, notes, and snippets.

@InsertNetan
Created June 24, 2016 08:51
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 InsertNetan/065081a11797670296113925f30b0f9a to your computer and use it in GitHub Desktop.
Save InsertNetan/065081a11797670296113925f30b0f9a to your computer and use it in GitHub Desktop.
extension Array {
func partition(predicate: (Element) -> Bool) -> ([Element],[Element]) {
var res = (satisfy:[Element](),notSatisfy:[Element]())
self.forEach { element in
if predicate(element){
res.satisfy.append(element)
} else {
res.notSatisfy.append(element)
}
}
return res
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment