Created
July 10, 2013 22:18
-
-
Save shigemk2/5970735 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
# -*- coding: euc-jp -*-" | |
def power(values): | |
for value in values: | |
print('powering %s' % value) | |
yield value | |
def adder(values): | |
for value in values: | |
print('adding to %s' % value) | |
if value % 2 == 0: | |
yield value + 3 | |
else: | |
yield value + 2 | |
elements = [1, 4, 7, 9, 12, 19] | |
res = adder(power(elements)) | |
print next(res) | |
# powering 1 | |
# adding to 1 | |
# 3 | |
print next(res) | |
# powering 4 | |
# adding to 4 | |
# 7 | |
print next(res) | |
# powering 7 | |
# adding to 7 | |
# 9 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment