Created
June 24, 2016 08:51
-
-
Save InsertNetan/065081a11797670296113925f30b0f9a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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