MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: List Operations


Try this:

mylist = {{1, a, b1, c1}, {1, a, b2, c2, c3}, {1, a,
b3, c4}, {2, b, z1}, {2, b, z2, c3}, {2, b, z3, c4, c5}, {2, b, z4},
{3,
     x, y1, c1, c5}, {3, x, y2, c3, c2}, {3, x, y3, c1}, {3,
     x, y4, c3, c1, c2}}

I have made the sublists of different length

Map[{#, Apply[Plus, Cases[mylist, {#, x_, y_, ___} -> x y]]} &, {1, 2,
3}]

{{1, a b1 + a b2 + a b3}, {2, b z1 + b z2 + b z3 +b z4}, {3, x y1 + x
y2 + x y3 + x y4}}

Hope this helps,

Cheers,

Brian


  • Prev by Date: Re: ViewPoint selector
  • Next by Date: Re: List Operations
  • Previous by thread: Re: List Operations
  • Next by thread: Re: List Operations