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
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']
>
>
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
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