Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created March 11, 2014 09:31
Show Gist options
  • Save tommorris/9482397 to your computer and use it in GitHub Desktop.
Save tommorris/9482397 to your computer and use it in GitHub Desktop.
def nested_map(f, maybe_iterable):
if hasattr(maybe_iterable, '__iter__'):
return [nested_map(f, x) for x in maybe_iterable]
else:
return f(maybe_iterable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment