I'd like to apply a function through a directory-like structure. As Python 3 supports lazy generators, I thought about using these to lazy evaluate the resulting list. This was my approach:
iterate = lambda func, d: (func(f) for f in listDir(d) if not f.isDir) + sum((iterate(func, d + f.name) for f in listDir(d) if f.isDir.), [])
This leads to unsupported operand type(s) for +: 'generator' and 'list'. Is there an idiomatic way to express this with lazy generators?
listDir accepts a path and returns a list of file information.