[Python-ideas] Proposal: A Reduce-Map Comprehension and a "last" builtin
Serhiy Storchaka
storchaka at gmail.com
Fri Apr 6 02:19:10 EDT 2018
05.04.18 19:52, Peter O'Connor пише:
> I propose a new "Reduce-Map" comprehension that allows us to write:
>
> signal = [math.sin(i*0.01) + random.normalvariate(0, 0.1)for iin range(1000)]
> smooth_signal = [average = (1-decay)*average + decay*xfor xin signalfrom average=0.]
Using currently supported syntax:
smooth_signal = [average for average in [0] for x in signal
for average in [(1-decay)*average + decay*x]]
More information about the Python-ideas
mailing list