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


Groups > comp.lang.python > #7083

RE: Lambda question

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jyoung79@kc.rr.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.032
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'slices': 0.07; 'terry': 0.07; 'recursion': 0.09; 'successive': 0.09; 'tail': 0.09; 'def': 0.12; 'docstring': 0.16; 'lambda': 0.16; 'n):': 0.16; 'reedy': 0.16; 'yield': 0.19; 'jan': 0.20; 'subject:question': 0.23; 'code': 0.24; 'thanks': 0.28; 'received:mail.rr.com': 0.29; 'received:10.127': 0.30; 'received:75.180': 0.30; 'received:75.180.132': 0.30; 'received:cdptpa-omtalb.mail.rr.com': 0.30; 'this.': 0.31; 'to:addr:python-list': 0.33; 'thank': 0.35; 'sense,': 0.35; 'else': 0.35; 'received:75': 0.35; 'received:rr.com': 0.36; 'ways': 0.37; 'subject:: ': 0.38; 'doing': 0.39; 'it!': 0.39; 'to:addr:python.org': 0.39; 'everyone': 0.40; 'really': 0.40; 'more': 0.60; 'your': 0.60; 'from:no real name:2**0': 0.61; 'taking': 0.64; 'incredible': 0.65; 'plus': 0.65; 'share': 0.67; 'jay': 0.84; 'packing': 0.84
Authentication-Results cdptpa-omtalb.mail.rr.com smtp.user=jyoung79@kc.rr.com; auth=pass (LOGIN)
X-Authority-Analysis v=1.1 cv=aeMH4JcVOnVr0LmJAzqEvfnmJyuaZufWdlng4HTRGCk= c=1 sm=0 a=IkcTkHD0fZMA:10 a=pucoitdqsAzEVdgCw3AA:9 a=QEXdDO2ut3YA:10 a=kPDWxe0Y+AmzkgVshK7X5A==:117
X-Cloudmark-Score 0
Date Mon, 6 Jun 2011 13:42:15 +0000
From <jyoung79@kc.rr.com>
To python-list@python.org
Subject RE: Lambda question
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding quoted-printable
X-Priority 3 (Normal)
Sensitivity Normal
X-Originating-IP
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.2488.1307367811.9059.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 82.94.164.166
X-Trace 1307367812 news.xs4all.nl 49179 [::ffff:82.94.164.166]:43504
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7083

Show key headers only | View raw


>>>>> f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc

> Packing tail recursion into one line is bad for both understanding and 
> refactoring. Use better names and a docstring gives
> 
> def group(seq, n):
>    'Yield from seq successive disjoint slices of length n plus the 
> remainder'
>    for i in range(0,len(seq), n):
>      yield seq[i:i+]
> 
> -- 
> Terry Jan Reedy

Thank you all very much for this incredible help!  The original code 
now makes sense, and I was thrilled to see better and more efficient 
ways of doing this.  Thanks for taking the time to share your 
thoughts as well as the excellent detail everyone shared…  I really 
appreciate it!

Jay

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


Thread

RE: Lambda question <jyoung79@kc.rr.com> - 2011-06-06 13:42 +0000

csiph-web