Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2009

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

Search the Archive

Re: Re: simple question

  • To: mathgroup at
  • Subject: [mg105313] Re: [mg105239] Re: [mg105202] simple question
  • From: Francisco Gutierrez <fgutiers2002 at>
  • Date: Fri, 27 Nov 2009 06:30:12 -0500 (EST)

Many thanks to Leonid, Valeri, Bob, and all the other friends who sent enlightening solutions to my simple problem.
As always, the variety of methods of attacking the problem is quite astonishing.
Best regards,

--- On Wed, 11/25/09, Bob Hanlon <hanlonr at> wrote:

From: Bob Hanlon <hanlonr at>
Subject: [mg105313] [mg105239] Re: [mg105202] simple question
To: mathgroup at
Date: Wednesday, November 25, 2009, 2:33 AM

groupBy[mat_, positions_] :=
GatherBy[mat, Part[#, positions] &]

Bob Hanlon

---- Francisco Gutierrez <fgutiers2002 at> wrote:

Dear List:
I have the following list:
I want to group it, so that the sublists of ejemplo1 that have identical values at positions 4 and 5 are gathered together. So I did the following code:
Split[ Sort[ejemplo1,#1[[4]]>=#2[[4]] && #1[[5]]>=#2[[5]] &],Take[#1,{4,5}]==Take[#2,{4,5}]&]

Works! The output in effect is:
precisely what I wanted.

Now, how can I create a function for the general case (instead of fixed positions 4 and 5, an arbitrary number of positions that act as "gathering parameter")?

  • Prev by Date: countour plot (in 3D)
  • Next by Date: Re: part assigned sequence behavior puzzling
  • Previous by thread: Re: simple question
  • Next by thread: Silent errors in Mathematica options, I think it should be detected.