Created
January 28, 2019 21:00
-
-
Save yoniLavi/6748cb1d562487e1dcbfa453ce951bf9 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
| """Hyperoperations implementation (https://en.wikipedia.org/wiki/Hyperoperation)""" | |
| from functools import reduce | |
| zeration = lambda a, b: b+1 | |
| addition = lambda a, b: reduce(lambda x, _: zeration(0, x), [None]*b, a) | |
| multiplication = lambda a, b: reduce(lambda x, _: addition(a, x), [None]*b, 0) | |
| exponentiation = lambda a, b: reduce(lambda x, _: multiplication(a, x), [None]*b, 1) | |
| tetration = lambda a, b: reduce(lambda x, _: exponentiation(a, x), [None]*b, 1) | |
| pentation = lambda a, b: reduce(lambda x, _: tetration(a, x), [None]*b, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment