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


Groups > comp.lang.python > #7083 > unrolled thread

RE: Lambda question

Started by<jyoung79@kc.rr.com>
First post2011-06-06 13:42 +0000
Last post2011-06-06 13:42 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#7083 — RE: Lambda question

From<jyoung79@kc.rr.com>
Date2011-06-06 13:42 +0000
SubjectRE: Lambda question
Message-ID<mailman.2488.1307367811.9059.python-list@python.org>
>>>>> 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web