fork download
  1. #! /usr/bin/env python3
  2.  
  3. from itertools import accumulate, repeat, takewhile
  4. from random import randint
  5.  
  6. def foo(x):
  7. if x % 5 == 0:
  8. print("スキップ")
  9. return False
  10. else:
  11. return True
  12.  
  13. def bar(x, y):
  14. print('hoge' if y % 7 == 0 else y)
  15. return x + y
  16.  
  17. def baz(x):
  18. if x > 500:
  19. print('break')
  20. return False
  21. else:
  22. return True
  23.  
  24. if __name__ == '__main__':
  25. for i in takewhile(baz,
  26. accumulate(filter(foo, (randint(*i) for i in repeat((0, 100)))),
  27. func = bar,
  28. initial = 0)):
  29. i
  30.  
Success #stdin #stdout 0.03s 10020KB
stdin
Standard input is empty
stdout
92
スキップ
hoge
26
53
22
hoge
スキップ
スキップ
スキップ
hoge
69
97
break