Last active
December 7, 2016 17:39
-
-
Save mrecachinas/1a1a2cfa9c348b9fbcccf83016a799f2 to your computer and use it in GitHub Desktop.
Public Extension Submission
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 String { | |
subscript(i: Int) -> Character { | |
return self[index(startIndex, offsetBy: i)] | |
} | |
subscript(r: Range<Int>) -> String { | |
return substring(with: index(startIndex, offsetBy: r.startIndex)..<index(startIndex, offsetBy: r.endIndex)) | |
} | |
} | |
extension Int { | |
func isPrime() -> Bool { | |
return self > 1 && !(2..<self).contains { self % $0 == 0 } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment