Re: How does this work?

2011-06-04 Thread Ben Finney
Jon Clements writes: > On Jun 5, 4:37 am, Ben Finney wrote: > > writes: > > > (http://stackoverflow.com/questions/312443/how-do-you-split-a-list-int...) > > > > This is an excellent example of why “clever” code is to be shunned. > > Whoever wrote this needs to spend more time trying to get thei

Re: How does this work?

2011-06-04 Thread Jon Clements
On Jun 5, 4:37 am, Ben Finney wrote: > writes: > > I was surfing around looking for a way to split a list into equal > > sections. I came upon this algorithm: > > > >>> f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc > > >>> f("Hallo Welt", 3) > > ['Hal', 'lo ', 'Wel', 't'] > >

Re: How does this work?

2011-06-04 Thread Ben Finney
writes: > I was surfing around looking for a way to split a list into equal > sections. I came upon this algorithm: > > >>> f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc > >>> f("Hallo Welt", 3) > ['Hal', 'lo ', 'Wel', 't'] > > (http://stackoverflow.com/questions/312443/how-do

How does this work?

2011-06-04 Thread jyoung79
I was surfing around looking for a way to split a list into equal sections. I came upon this algorithm: >>> f = lambda x, n, acc=[]: f(x[n:], n, acc+[(x[:n])]) if x else acc >>> f("Hallo Welt", 3) ['Hal', 'lo ', 'Wel', 't'] (http://stackoverflow.com/questions/312443/how-do-you-split-a-list-int