Created
January 28, 2015 08:59
-
-
Save hartbit/e492376a8851ea6586a8 to your computer and use it in GitHub Desktop.
IntegerLiteralConvertible answer to http://www.fewbutripe.com/swift/math/2015/01/27/solutions-to-natural-numbers.html
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 Nat: IntegerLiteralConvertible { | |
init(integerLiteral value: IntegerLiteralType) { | |
switch (value) { | |
case 0: | |
self = .Zero | |
default: | |
self = .Succ(Nat(integerLiteral: value - 1)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment