3 ms·
That chained syntax is entirely doable in Python. I see no reason to object to a1, a2, a3 as intermediate steps in a computation. They don't have a name in you
by nerpderp82 6y ago
That chained syntax is entirely doable in Python.
I see no reason to object to a1, a2, a3 as intermediate steps in a computation. They don't have a name in your chained style, why does the name matter with the intermediates?
This is very clunky, but it is similar, could be streamlined.
import aiostream
from aiostream.stream import pipe
import operator
v = aiostream.stream.iterate(set("a ab abc ddd eeee abasdfadf".split())) \
| pipe.filter(lambda x: x.startswith('a')) \
| pipe.map(lambda x: len(x)) \
| pipe.reduce(operator.add, 0)
print(await aiostream.stream.list(v))
- keithalewis 6y ago+1 for your sense of humor.