Re: List Operations
- To: mathgroup at smc.vnet.net
- Subject: [mg65691] Re: List Operations
- From: "J Siehler" <jsiehler at gmail.com>
- Date: Sun, 16 Apr 2006 01:44:47 -0400 (EDT)
- References: <e1nn6s$lmm$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I assume when you say "the sublists have different length" you mean we're looking at a list of triples, but there may be a different number of triples present for any given first entry. example = {{3, a, b}, {1, a, b}, {3, x, y}, {2, x, y}, {2, x, y}, {n, q, r}, {5, p, q}, {1, w, z}, {3, a, b}, {2, x, y}, {3, q, r}, {n, p, r}}; sopByIndex[l_] := Map[ {#[[1, 1]], Dot @@ Rest[Transpose[#]]} &, Split[Sort[l], #1[[1]] == #2[[1]] &] ] example // sopByIndex