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
| // Demonstrates some rather elementary points about code points vs elements | |
| import Foundation | |
| import Swift | |
| extension String { | |
| func canonize() -> [Character] { | |
| return Array(precomposedStringWithCanonicalMapping) | |
| } | |
| static func decanonize(chars: [Character]) -> String { |
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
| // This new version seems to be syntactically correct, | |
| // but it crashes together with Xcode as of beta 3. | |
| // (radar link should appear here) | |
| // Find smallest N such that f(N) = nil. | |
| func exhaust<T>(fun: Int -> T?) -> Int { | |
| var index = 0 | |
| while fun(index) { index++ } | |
| return index | |
| } |
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
| class Unwrapper<T, R> { | |
| let failed:R? | |
| let values:[T] | |
| init(values: [T] = [], failed:R? = nil) { | |
| self.values = values | |
| self.failed = failed | |
| } | |
| class func unwrap(value:T?, elseReturn safe:R) -> Unwrapper<T, R> { |
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
| enum State { | |
| case Success(value:String) | |
| case Error(error:NSError) | |
| } | |
| class Bound:Printable { | |
| let pointer:NSErrorPointer | |
| var state:State | |
| var step:Int = 0 | |
NewerOlder