Handling 3 operands in an expression without raising an exception
giacomo boffi
pecore at pascolo.net
Sun Sep 29 17:39:03 EDT 2013
Joel Goldstick <joel.goldstick at gmail.com> writes:
> On Sun, Sep 29, 2013 at 11:28 AM, giacomo boffi <pecore at pascolo.net> wrote:
>
> Νίκος <nikos.gr33k at gmail.com> writes:
>
> > IF it can also be written in one-line
>
> def f(x,n,w):return(lambda y=f(x[::2],n/2,w[::2]),z=f(x[1::2],n/2,w
> [::2]):reduce(lambda x,y:x+y,zip(*[(y[k]+w[k]*z[k],y[k]-w[k]*z[k]) for k in
> range(n/2)])))()if n>1 else x
>
> I've been reading along and learning some really obscure coding
> patterns.
well, the obscure patterns aren't mine, they were contributed by some
it.comp.python regulars, to which credit is due if credit is due
(please ask google groups for the individual contributions)
> why?
to show a recreational one liner from which Νίκος could learn
something, one way or another
--
X = f(x,n,[exp(-2*pi*1j*k/n) for k in range(n/2)])
More information about the Python-list
mailing list