Skip to content

Instantly share code, notes, and snippets.

@kunigami
Last active December 26, 2019 17:18
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 kunigami/7994d403827935cb065959b3accb121a to your computer and use it in GitHub Desktop.
Save kunigami/7994d403827935cb065959b3accb121a to your computer and use it in GitHub Desktop.
def typed_reduce(xs: List[str], f: Callable[[str, str], str], x0: str) -> str:
r = x0
for x in xs:
r = f(r, x)
return r
print(typed_reduce(['a', 'b', 'c'], lambda x, y: x + y, ''))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment