Last active
August 29, 2015 14:18
-
-
Save joanmolinas/4139d06a792c7364565c to your computer and use it in GitHub Desktop.
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
prefix operator ^^ {} | |
prefix func ^^ (rhs : Int) -> Int { | |
return rhs < 0 ? 0 : rhs <= 2 ? 1 : ^^(rhs - 1) + ^^(rhs - 2) | |
} | |
postfix operator ^^ {} | |
postfix func ^^ (lhs : Int) -> Int { | |
return lhs < 0 ? 0 : lhs <= 2 ? 1 : ^^(lhs - 1) + ^^(lhs - 2) | |
} | |
infix operator ^+^ { associativity right precedence 140} | |
func ^+^ (lhs : Int, rhs : Int) -> Int { | |
return ^^rhs + ^^lhs | |
//USAGE | |
^^(-1) // OUTPUT -> 0 | |
15^^ // OUTPUT -> 987 | |
5^+^6 //OUTPUT -> 21 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment