Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Python presentations

Received: by 10.180.24.135 with SMTP id u7mr654178wif.3.1348233586601;
        Fri, 21 Sep 2012 06:19:46 -0700 (PDT)
Path: q11ni9085046wiw.1!nntp.google.com!feeder2.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!nntp.club.cc.cmu.edu!feeder.erje.net!news2.arglkargh.de!news.mixmin.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Date: Fri, 14 Sep 2012 13:47:57 +0200
From: Alexander Blinne <n...@blinne.net>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.24) Gecko/20100411 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666
MIME-Version: 1.0
Newsgroups: comp.lang.python
Subject: Re: Python presentations
References: <mailman.617.1347552022.27098.python-list@python.org> <k2t1f9$4jp$1@news.albasani.net> <06a1a81b-246b-4e7b-ba34-4701f46889c8@googlegroups.com> <50525f48$0$6573$9b4e6d93@newsspool3.arcor-online.net> <mailman.646.1347575926.27098.python-list@python.org>
In-Reply-To: <mailman.646.1347575926.27098.python-list@python.org>
Lines: 20
Message-ID: <5053196e$0$6578$9b4e6d93@newsspool3.arcor-online.net>
Organization: Arcor
NNTP-Posting-Date: 14 Sep 2012 13:47:58 CEST
NNTP-Posting-Host: 6d3e0fc3.newsspool3.arcor-online.net
X-Trace: DXC=54M_fXTW;bZaoembcbF;DQMcF=Q^Z^V3X4Fo<]lROoRQ8kF<OcfhCO[LjXmbhGDeCYaj=_50PemT\]bA\LVClcRYS>BV_:foeG_
X-Complaints-To: usenet-abuse@arcor.de
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On 14.09.2012 00:38, Chris Angelico wrote:
> On Fri, Sep 14, 2012 at 8:33 AM, Alexander Blinne <n...@blinne.net> wrote:
>> def powerlist(x,n):
>>     if n==1:
>>         return [1]
>>     p = powerlist(x,n-1)
>>     return p + [p[-1]*x]
> 
> Eh, much simpler.
> 
> def powerlist(x,n):
>   return [x*i for i in xrange(n-1)]

I suppose you meant:

def powerlist(x,n):
  return [x**i for i in xrange(n-1)]

But this is less efficient, because it needs more multiplications (see
Horner's method)