Last active
April 12, 2018 05:34
-
-
Save uruly/5786b7d527888d863ef5d929515bdec3 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 findIndex(includeElement: (Element) -> Bool) -> [Int] { | |
| var indexArray:[Int] = [] | |
| for (index, element) in enumerated() { | |
| if includeElement(element) { | |
| indexArray.append(index) | |
| } | |
| } | |
| return indexArray | |
| } | |
| func findAll(includeElement: (Element) -> Bool) -> [(Int, Element)] { | |
| let seq = zip(0..<self.count, self) | |
| return seq.filter() { includeElement($0.1) } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment