Skip to content

Instantly share code, notes, and snippets.

@pykong
Last active October 22, 2017 11:44
Show Gist options
  • Save pykong/a7ab8ff38b1a64edae8b1451868f3830 to your computer and use it in GitHub Desktop.
Save pykong/a7ab8ff38b1a64edae8b1451868f3830 to your computer and use it in GitHub Desktop.
Can be used to implement memoization as well.
def mt(a, memo=[]):
a += 1
print(a)
memo.append(a)
print(memo)
mt(1)
mt(2)
mt(3)
[2]
3
[2, 3]
4
[2, 3, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment