Re: How to store some elements from a list into another

2017-06-13 Thread Grant Edwards
On 2017-06-13, Peter Otten <__pete...@web.de> wrote: > Grant Edwards wrote: > >> On 2017-06-13, Peter Otten <__pete...@web.de> wrote: >> def edges(items): # where items is a non-empty iterator first = next(items) last = functools.reduce(sekond, items, first) return

Re: How to store some elements from a list into another

2017-06-13 Thread Peter Otten
Grant Edwards wrote: > On 2017-06-13, Peter Otten <__pete...@web.de> wrote: > >>> def edges(items): # where items is a non-empty iterator >>> first = next(items) >>> last = functools.reduce(sekond, items, first) >>> return [first, last] >>> >>> Of course, right? >> >> Yeah, reduce()

Re: How to store some elements from a list into another

2017-06-13 Thread Grant Edwards
On 2017-06-13, Peter Otten <__pete...@web.de> wrote: >> def edges(items): # where items is a non-empty iterator >> first = next(items) >> last = functools.reduce(sekond, items, first) >> return [first, last] >> >> Of course, right? > > Yeah, reduce() is certainly the cherry on the ite

Re: How to store some elements from a list into another

2017-06-13 Thread Peter Otten
Jussi Piitulainen wrote: > Peter Otten writes: > > ... > >> def edges(items): >> first = last = next(items) >> for last in items: >> pass >> return [first, last] > > ... > >> However, this is infested with for loops. Therefore > > ... > >> I don't immediately see what to

Re: How to store some elements from a list into another

2017-06-13 Thread breamoreboy
On Monday, June 12, 2017 at 7:33:03 PM UTC+1, José Manuel Suárez Sierra wrote: > Hello, > I am stuck with a (perhaps) easy problem, I hope someone can help me: > > My problem is: > I have a list of lists like this one: > [[55, 56, 57, 58, 83, 84, 85, 86, 89, 90, 91, 92, 107, 108, 109, 110, 111, >

Re: How to store some elements from a list into another

2017-06-13 Thread Jussi Piitulainen
Peter Otten writes: ... > def edges(items): > first = last = next(items) > for last in items: > pass > return [first, last] ... > However, this is infested with for loops. Therefore ... > I don't immediately see what to do about the for loop in edges(), so > I'll use the t

Re: How to store some elements from a list into another

2017-06-13 Thread Peter Otten
Jussi Piitulainen wrote: > breamore...@gmail.com writes: > >> On Monday, June 12, 2017 at 7:33:03 PM UTC+1, José Manuel Suárez Sierra >> wrote: >>> Hello, >>> I am stuck with a (perhaps) easy problem, I hope someone can help me: >>> >>> My problem is: >>> I have a list of lists like this one: >>

Re: How to store some elements from a list into another

2017-06-13 Thread Jussi Piitulainen
breamore...@gmail.com writes: > On Monday, June 12, 2017 at 7:33:03 PM UTC+1, José Manuel Suárez Sierra wrote: >> Hello, >> I am stuck with a (perhaps) easy problem, I hope someone can help me: >> >> My problem is: >> I have a list of lists like this one: >> [[55, 56, 57, 58, 83, 84, 85, 86, 89,

Re: How to store some elements from a list into another

2017-06-12 Thread Thomas Jollans
On 12/06/17 20:32, José Manuel Suárez Sierra wrote: > Hello, > I am stuck with a (perhaps) easy problem, I hope someone can help me: > > My problem is: > I have a list of lists like this one: > [[55, 56, 57, 58, 83, 84, 85, 86, 89, 90, 91, 92, 107, 108, 109, 110, 111, > 117, 118, 119, 120, 128, 1

Re: How to store some elements from a list into another

2017-06-12 Thread MRAB
On 2017-06-12 19:32, José Manuel Suárez Sierra wrote: Hello, I am stuck with a (perhaps) easy problem, I hope someone can help me: My problem is: I have a list of lists like this one: [[55, 56, 57, 58, 83, 84, 85, 86, 89, 90, 91, 92, 107, 108, 109, 110, 111, 117, 118, 119, 120, 128, 129, 130, 1

How to store some elements from a list into another

2017-06-12 Thread José Manuel Suárez Sierra
Hello, I am stuck with a (perhaps) easy problem, I hope someone can help me: My problem is: I have a list of lists like this one: [[55, 56, 57, 58, 83, 84, 85, 86, 89, 90, 91, 92, 107, 108, 109, 110, 111, 117, 118, 119, 120, 128, 129, 130, 131, 135, 136, 137, 138, 184, 185, 186, 187, 216, 217, 2