Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.069 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'python': 0.07; 'def': 0.13; 'am,': 0.14; 'wrote:': 0.14; 'subject:python': 0.15; 'arrays.': 0.16; 'readable': 0.16; 'take?': 0.16; 'figure': 0.18; 'perl': 0.19; 'tue,': 0.20; 'writes:': 0.20; 'language': 0.20; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'integer': 0.23; 'parameters': 0.26; "i'm": 0.26; 'message-id:@mail.gmail.com': 0.28; 'sort': 0.30; 'does': 0.31; 'to:addr:python-list': 0.32; 'should': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'strings': 0.38; 'received:google.com': 0.38; 'less': 0.38; 'but': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'how': 0.39; 'header:Received:5': 0.40; '8bit%:4': 0.60; 'played': 0.60; '2011': 0.62; 'noise': 0.68; 'teach': 0.69; 'subject:one': 0.73; 'joke': 0.84; 'received:209.85.210.174': 0.84; 'received:mail- iy0-f174.google.com': 0.84; 'seriously,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=MDy2l5KMniWdxbfBIzh3ZTUMcvAtAmlsNKg763OFCKI=; b=x3k5pWI6tPY9XnBl/EJTyoj5BfNXWk9PgzlPnQOJiZVxslFxejQa/N6BDQXfPfFDg6 rAO6Z6dvyWHh1wgdSAt9rg288spaVIUbZEDBq18Blh/JbAiYkTF6SAi7oe89S7RybOTm qCSH0dakYrZTeAFemRzW039Yj41TZ9dwqd17A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=VHRdU5+Jpre+vvsBv6lKTMdZqbabXDCwYHs7OVFSgfH3/ggsnYPHqtO3cgFmOSjtjH DUvZX0JjiKqRLmayPVutYUJ+NMD7NsqACpLyYnzZvYWHrEosoKFC9yUyC1BLFHKhp44d xavKeGspKTEyNXfARAv3Mrg/M2c2Iu8G2NGf8= MIME-Version: 1.0 In-Reply-To: <86k4f9wzgx.fsf@aiuole.stru.polimi.it> References: <86k4f9wzgx.fsf@aiuole.stru.polimi.it> Date: Tue, 5 Apr 2011 07:46:39 +1000 Subject: Re: Fun python 3.2 one-liner From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1301953602 news.xs4all.nl 41117 [::ffff:82.94.164.166]:55715 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2602 On Tue, Apr 5, 2011 at 6:09 AM, gb wrote: > harrismh777 writes: > >> Seriously, these little one liners teach me more about the python >> language in less time than [...] > > def f(x,n,w): return x if n=3D=3D1 else\ > =A0 =A0(lambda x0=3Df(x[::2],n/2,w[::2]),\ > =A0 =A0 =A0 =A0 =A0 =A0x1=3Df(x[1::2],n/2,w[::2]): reduce(lambda a,b: a+b= ,\ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0zip(*[(x0[k]+w[k]*x1[k],\ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 x0[k]-w[k]*x1[k])\ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 for k in range(n/2)])))() > > it was a joke of sort played on it.comp.lang.python (Remind me how it is that Python code is more readable than line noise or Perl code?) What sort of parameters does this take? So far all I can figure out is that n is an integer and x and w are sliceables, but I'm not sure whether x and w should be strings or arrays. ChrisA