(iter, n=0, fn=None)
| 66 | |
| 67 | |
| 68 | def chunks(iter, n=0, fn=None): |
| 69 | arr = [] |
| 70 | for i, x in enumerate(iter): |
| 71 | arr.append(x) |
| 72 | if len(arr) == (fn(i) if fn else n): |
| 73 | yield arr |
| 74 | arr = [] |
| 75 | |
| 76 | if arr: |
| 77 | yield arr |
| 78 | |
| 79 | |
| 80 | def group(arr, fn): |
nothing calls this directly
no outgoing calls
no test coverage detected