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


Groups > comp.lang.python > #15110

Fast recursive generators?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <michaelm@plumbersstock.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.029
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'func': 0.09; 'likely.': 0.09; 'lambda': 0.16; 'this:': 0.16; 'thanks,': 0.18; 'received:209.85.210.174': 0.18; 'received:mail- iy0-f174.google.com': 0.18; 'this?': 0.21; 'trying': 0.21; "doesn't": 0.22; 'code': 0.25; 'guess': 0.26; "i'm": 0.27; 'repeatedly': 0.28; 'bit': 0.28; 'pass': 0.29; 'message- id:@mail.gmail.com': 0.29; '-1,': 0.30; 'clean.': 0.30; 'subject:?': 0.31; 'seem': 0.31; 'michael': 0.31; 'values': 0.32; 'list': 0.32; 'dependent': 0.32; 'there': 0.33; 'to:addr:python- list': 0.33; 'filter': 0.34; 'like:': 0.34; 'but': 0.37; 'something': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'to:addr:python.org': 0.39; "i'd": 0.40; "it's": 0.40; 'where': 0.40; 'more': 0.60; 'from:addr:michaelm': 0.84
MIME-Version 1.0
From Michael McGlothlin <michaelm@plumbersstock.com>
Date Fri, 28 Oct 2011 12:10:14 -0600
Subject Fast recursive generators?
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.2288.1319825439.27778.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1319825439 news.xs4all.nl 6869 [2001:888:2000:d::a6]:60351
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15110

Show key headers only | View raw


I'm trying to generate a list of values where each value is dependent
on the previous value in the list and this bit of code needs to be
repeatedly so I'd like it to be fast. It doesn't seem that
comprehensions will work as each pass needs to take the result of the
previous pass as it's argument. map() doesn't seem likely. filter() or
reduce() seem workable but not very clean. Is there a good way to do
this? About the best I can get is this:

l = [ func ( start ) ]
f = lambda a: func ( l[-1] ) or a
filter ( f, range ( big_number, -1, -1 ) )


I guess I'm looking for something more like:

l = do ( lambda a: func ( a ), big_number, start )


Thanks,
Michael McGlothlin

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


Thread

Fast recursive generators? Michael McGlothlin <michaelm@plumbersstock.com> - 2011-10-28 12:10 -0600

csiph-web