Re: List Operations
- To: mathgroup at smc.vnet.net
- Subject: [mg65707] Re: List Operations
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 16 Apr 2006 01:45:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 4/14/06 at 4:32 AM, lectorz at mail.ru (LectorZ) wrote: >My question: >mylist={{1,a, b},{1,a, b},{1,a, >b},{2,b,z},{2,b,z},{2,b,z},{2,b,z},....,{n,x,y},{n,x,y},{n,x,y},...{ >n,x,y}} >The sublists are of different length. >I need to calculate the product between the 2nd and 3rd element of >every sublist (e.g. a*b) and then add them up according to the 1st >element: sum of all products where the 1st element is 1, 2, ...n. >The result should be a list like that: >{{1,a*b+a*b+a*b},{2,b*z+b*z+b*z+b*z}, ...,{n, x*y+x*y+x*y+...+x*y}} Try {#[[1,1]],Rest[#[[2]]].Rest[#[[3]]]}&/@Partition[mylist,3] -- To reply via email subtract one hundred and four