Created
September 6, 2020 14:03
-
-
Save pilcrow/449d6936525377181f875a828f2f9462 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
def coalesce(*args): | |
# return first(lambda x: x is not None, args) | |
return next(_ for _ in args if _ is not None) | |
def first(selector, iterable, default = None): | |
return next((_ for _ in iterable if selector(_)), default) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment