Skip to content

Instantly share code, notes, and snippets.

@jarshwah
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarshwah/0998143317f5ccc093b3 to your computer and use it in GitHub Desktop.
Save jarshwah/0998143317f5ccc093b3 to your computer and use it in GitHub Desktop.
goal in python
def g(letters=None):
if letters: return 'gal'
goal = ['go']
def o(letters=None):
assert letters is None or letters == 'al'
if letters:
goal.append(letters)
return ''.join(goal)
goal.append('o')
return o
return o
if __name__ == '__main__':
print(g('al'))
print(g()('al'))
print(g()()('al'))
print(g()()()()()('al'))
from functools import partial
def f(times, letters=None):
if letters:
return 'g'+('o'*times)+letters
return partial(f, times+1)
g=partial(f, 0)
if __name__ == '__main__':
print(g('al'))
print(g()('al'))
print(g()()('al'))
print(g()()()()()('al'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment