Created
June 11, 2015 18:13
-
-
Save doozMen/4a7cdc7996c03cf6f460 to your computer and use it in GitHub Desktop.
Array index extension
This file contains 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 indexes<T>(xs: [T], check: T -> Bool) -> [Int] { | |
var result = [Int]() | |
var i = 0 | |
for x in xs { | |
if check(x) { | |
result.append(i) | |
} | |
i++ | |
} | |
return result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment