Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-2.dfn.de!news.dfn.de!storethat.news.telefonica.de!feedme.news.telefonica.de!telefonica.de!diesel.cu.mi.it!.POSTED!not-for-mail From: giacomo boffi Newsgroups: comp.lang.python Subject: Re: Handling 3 operands in an expression without raising an exception Date: Sun, 29 Sep 2013 23:39:03 +0200 Organization: The Sun and the Rain. Lines: 25 Message-ID: <87a9ivi9zc.fsf@pascolo.net> References: <87eh87ir51.fsf@pascolo.net> NNTP-Posting-Host: ppp-144-7.21-151.libero.it Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-7 Content-Transfer-Encoding: 8bit X-Trace: virtdiesel.mng.cu.mi.it 1380490743 25223 151.21.7.144 (29 Sep 2013 21:39:03 GMT) X-Complaints-To: abuse@diesel.cu.mi.it NNTP-Posting-Date: Sun, 29 Sep 2013 21:39:03 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.5-b32 (linux) Cancel-Lock: sha1:wg6COpoF9pHnbgOXSffpvFpfyB4= Xref: csiph.com comp.lang.python:55038 Joel Goldstick writes: > On Sun, Sep 29, 2013 at 11:28 AM, giacomo boffi wrote: > > Νίκος 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)])