Skip to content

Instantly share code, notes, and snippets.

@justinfay
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save justinfay/aacb055415339570a931 to your computer and use it in GitHub Desktop.

Select an option

Save justinfay/aacb055415339570a931 to your computer and use it in GitHub Desktop.
>>> def counter():
... def wrapper():
... wrapper.count += 1
... return wrapper.count
... wrapper.count = 0
... return wrapper
...
>>> def while_rec(func, pred):
... result = func()
... if pred(result) is False:
... return result
... return while_rec(func, pred)
...
>>> while_rec(counter(), lambda x: x != 10)
10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment