reduced() is complementary to the greduce generator. Use this function to keep the current value of the reduced stream. This is analog to reduce(lst) where reduce() is Pythons builtin reduce and lst is a list.
(stream_red)
| 34 | |
| 35 | |
| 36 | def reduced(stream_red): |
| 37 | ''' |
| 38 | reduced() is complementary to the greduce generator. |
| 39 | Use this function to keep the current value of the reduced stream. This |
| 40 | is analog to reduce(lst) where reduce() is Pythons builtin reduce and lst |
| 41 | is a list. |
| 42 | ''' |
| 43 | res = stream_red.next() |
| 44 | if res is None: |
| 45 | res = stream_red.throw(YieldResult) |
| 46 | stream_red.next() |
| 47 | return res |
| 48 | for item in stream_red: |
| 49 | if item is None: |
| 50 | break |
| 51 | else: |
| 52 | res = item |
| 53 | return res |
| 54 | |
| 55 | # |
| 56 | # Example 1 |
no test coverage detected