我应该如何从这个结构出发呢?
>>> input = ['a', 'b', 'c']
到这个
>>> output
['a', 'a/b', 'a/b/c']
以优雅(功能性)的方式?
目前我有这个:
>>> from functools import reduce
>>> res = []
>>> for i in range(len(input)):
... res.append(reduce(lambda a, b: a + '/' + b, input[:i+1]))
...
>>> res
['a', 'a/b', 'a/b/c']