Last active
August 29, 2015 14:06
-
-
Save mvcisback/dcc78408f2c2986c9c8a to your computer and use it in GitHub Desktop.
src to sink
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 infix import or_infix as infix | |
from more_itertools import consumer | |
@infix | |
def to(src, sink): | |
def _to(): | |
for x in src: | |
sink.send(x) | |
return _to | |
def source(): | |
yield from range(5) | |
@consumer | |
def sink(): | |
while True: | |
x = yield | |
print(x +1) | |
def main(): | |
plan = source() |to| sink() | |
plan() | |
if __name__ == '__main__': | |
main() |
This doesn't compose well atm....doesn't yield output
I think there needs to be a distinction between sending and receiving that's not currently available
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: