MathGroup Archive 2006

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

Search the Archive

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


  • Prev by Date: Re: List Operations
  • Next by Date: Problem with limiits
  • Previous by thread: Re: List Operations
  • Next by thread: Re: List Operations