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
//------------------------------------------------------------------------------ | |
// The following compiles and works, but see comments for 2 compiler crashers. | |
//------------------------------------------------------------------------------ | |
protocol DefaultInitializable { init() } | |
extension Int: DefaultInitializable {} | |
// Hople = Homogeneous tuple / static array implemented using recursive structs. | |
protocol HopleType : DefaultInitializable { | |
typealias Element: DefaultInitializable | |
subscript(index: Int) -> Element { get set } | |
} |
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
struct SA<T> { | |
let v: T | |
init(_ v: T) { self.v = v } | |
} | |
typealias SB = SA<(Int, Int)> | |
typealias SC = SA<W> | |
typealias W = (Int, Int) |
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
// (Xcode 7.1 beta 2) | |
// Background: | |
// I wanted to replace these two overloads with a generic function/method (working for Float and Double): | |
// func oldRemoveSrgbGamma(v: Float) -> Float { | |
// return (v <= 0.04045) ? v * (1.0 / 12.92) : pow((v + 0.055) * (1.0 / (1.0 + 0.055)), 2.4) | |
// } | |
// func oldRemoveSrgbGamma(v: Double) -> Double { | |
// return (v <= 0.04045) ? v * (1.0 / 12.92) : pow((v + 0.055) * (1.0 / (1.0 + 0.055)), 2.4) | |
// } |
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
protocol Bit {} | |
protocol IsSet {} | |
protocol IsClr {} | |
struct Set : Bit, IsSet {} | |
struct Clr : Bit, IsClr {} | |
protocol NandOp { typealias Result } | |
extension NandOp { typealias Result = Set } |
NewerOlder