Created
December 11, 2015 21:55
-
-
Save snaffi/06b1c2746f5c017638b5 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
def supermap(funcs, iterable): | |
for item in iterable: | |
for func in funcs: | |
item = func(item) | |
yield item | |
def incr(val): | |
return val + 1 | |
def incr_2(val): | |
return val + 5 | |
res = supermap([incr, incr_2], [1, 2, 3, 4]) | |
print([i for i in res]) | |
# [7, 8, 9, 10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Чтобы сохранить семантику оригинального map, я бы предложил следующий вариант: