Re: [Tutor] Would somebody kindly...

2014-10-29 Thread Clayton Kirkwood
>-Original Message- >From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On >Behalf Of Dave Angel >Sent: Wednesday, October 29, 2014 5:30 AM >To: tutor@python.org >Subject: Re: [Tutor] Would somebody kindly... > >"Clayton Kirkwood" Wrote in message: >> >> >> !-Original M

Re: [Tutor] question on array Operation

2014-10-29 Thread Steven D'Aprano
On Wed, Oct 29, 2014 at 05:08:28PM +0100, jarod...@libero.it wrote: > Dear All, > > I have a long matrix where I have the samples (1to n) and then I have (1to j > )elements. > I would like to count how many times each j element are present on each > samples. Jarod, looking at your email addres

Re: [Tutor] question on array Operation

2014-10-29 Thread Alan Gauld
On 29/10/14 16:08, jarod...@libero.it wrote: I have a long matrix where I have the samples (1to n) and then I have (1to j )elements. I would like to count how many times each j element are present on each samples. That probably makes sense to you but it doesn't to me. Lets assuyme you have n=

Re: [Tutor] question on array Operation

2014-10-29 Thread Peter Otten
jarod...@libero.it wrote: > Dear All, > > I have a long matrix where I have the samples (1to n) and then I have (1to > j )elements. > I would like to count how many times each j element are present on each > samples. > > So the question is which is the best algoritm for obtain the results. The

[Tutor] question on array Operation

2014-10-29 Thread jarod...@libero.it
Dear All, I have a long matrix where I have the samples (1to n) and then I have (1to j )elements. I would like to count how many times each j element are present on each samples. So the question is which is the best algoritm for obtain the results. The result I want is a table like that. A

Re: [Tutor] Would somebody kindly...

2014-10-29 Thread Dave Angel
"Clayton Kirkwood" Wrote in message: > > > !-Original Message- > !From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On > !Behalf Of Dave Angel > !Sent: Tuesday, October 28, 2014 6:34 PM > !To: tutor@python.org > !Subject: Re: [Tutor] Would somebody kindly... > ! > ! > !> >

Re: [Tutor] Would somebody kindly...

2014-10-29 Thread Steven D'Aprano
On Tue, Oct 28, 2014 at 04:13:19PM -0700, Clayton Kirkwood wrote: > Explain this double speak(>: > > [pair for pair in values if key == pair[0]] Translated to a regular for-loop: result = [] for pair in values: if key == pair[0]: result.append(pair) It iterates over the sequence `v

Re: [Tutor] Would somebody kindly...

2014-10-29 Thread Alan Gauld
On 29/10/14 04:33, Clayton Kirkwood wrote: !If we'd wanted the new list to contain double the original values we'd !write: ! ! [ pair*2 for pair in values if key == pair[0] ] Ok, I am somewhat confused again. In the original example up above, it appears that the pair list or tuple gets overri

Re: [Tutor] Would somebody kindly...

2014-10-29 Thread Cameron Simpson
On 28Oct2014 21:33, Clayton Kirkwood wrote: !If we'd wanted the new list to contain double the original values we'd !write: ! ! [ pair*2 for pair in values if key == pair[0] ] Ok, I am somewhat confused again. In the original example up above, it appears that the pair list or tuple gets overr

Re: [Tutor] Would somebody kindly...

2014-10-29 Thread Cameron Simpson
On 28Oct2014 21:33, Clayton Kirkwood wrote: !From: Cameron Simpson [mailto:c...@zip.com.au] !Let me try a less wordy diagram. You will need to be displaying in a !constant width font :-) ! ! [ pair for pair in values if key == pair[0] ] ! -- the expression that accrues in the resulting