Created
March 9, 2021 16:11
-
-
Save acdimalev/0e1efb126a300aeccf1df594a8d1d0b7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Python 3 is an iterator-first language. | |
# `bind` and `join` are reaching wider adoption under the names `flatmap` and `flatten`. | |
def flatmap(f, xs): | |
return (y for x in xs for y in f(x)) | |
def flatten(xs): | |
return (y for x in xs for y in x) | |
# These don't match the `zip(*args)` behavior of `map`, but I have never actually seen that used. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment