Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2602

Re: Fun python 3.2 one-liner

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 <rosuav@gmail.com>
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 <df2af546-af99-4e69-bc8e-38c21a045a29@z27g2000prz.googlegroups.com> <o%pkp.365$0s5.220@newsfe17.iad> <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 <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.20.1301953602.9059.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Tue, Apr 5, 2011 at 6:09 AM, gb <gb@cabiate.it> wrote:
> harrismh777 <harrismh777@charter.net> 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==1 else\
>    (lambda x0=f(x[::2],n/2,w[::2]),\
>            x1=f(x[1::2],n/2,w[::2]): reduce(lambda a,b: a+b ,\
>                                      zip(*[(x0[k]+w[k]*x1[k],\
>                                             x0[k]-w[k]*x1[k])\
>                                             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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Fun python 3.2 one-liner harrismh777 <harrismh777@charter.net> - 2011-03-29 14:00 -0500
  Re: Fun python 3.2 one-liner gb <gb@cabiate.it> - 2011-04-04 22:09 +0200
    Re: Fun python 3.2 one-liner Chris Angelico <rosuav@gmail.com> - 2011-04-05 07:46 +1000
      Re: Fun python 3.2 one-liner Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-04-05 10:16 +1200
        Re: Fun python 3.2 one-liner Chris Angelico <rosuav@gmail.com> - 2011-04-05 08:45 +1000
        Re: Fun python 3.2 one-liner Emile van Sebille <emile@fenx.com> - 2011-04-04 15:46 -0700
      Re: Fun python 3.2 one-liner Giacomo Boffi <giacomo.boffi@polimi.it> - 2011-04-05 07:36 +0200

csiph-web