MathGroup Archive 2006

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

Search the Archive

Re: List Operations


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