Skip to content

Instantly share code, notes, and snippets.

@glossawy
Created July 12, 2022 20:19
Show Gist options
  • Save glossawy/9219ed5768a5db607415520223dd2b86 to your computer and use it in GitHub Desktop.
Save glossawy/9219ed5768a5db607415520223dd2b86 to your computer and use it in GitHub Desktop.
Demonstrating the successor function
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