Created
July 12, 2022 20:19
-
-
Save glossawy/9219ed5768a5db607415520223dd2b86 to your computer and use it in GitHub Desktop.
Demonstrating the successor function
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
class Duck: | |
def __init__(self, quacks=0): | |
self._quacks = quacks | |
def __add__(self, more_quacks): | |
return Duck(self._quacks + more_quacks) | |
def __str__(self): | |
return ('quack ' * self._quacks)[:-1] | |
succ = lambda i: i + 1 | |
print(f'Your Int -> Int function: succ(1) == {succ(1)}') | |
print(f'My Int -> Int function: succ(Duck(1)) == {succ(Duck(1))}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment