Created
March 14, 2018 22:09
-
-
Save zackmdavis/65d5d8d8c4fd4638e2e20eab1615a1d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional, TypeVar | |
T = TypeVar('T') | |
U = TypeVar('U') | |
def option_map(arg: Optional[T], fn: Callable[[T], U]) -> Optional[U]: | |
if arg is not None: | |
return fn(arg) | |
else: | |
return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment