MathGroup Archive 2010

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

Search the Archive

Re: Question about Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106558] Re: [mg106544] Question about Mathematica
  • From: Tomas Garza <tgarza10 at msn.com>
  • Date: Sat, 16 Jan 2010 06:12:02 -0500 (EST)
  • References: <201001151200.HAA07995@smc.vnet.net>

Assuming there is a single minimum in each sub-table (otherwise, the prob=
lem must be specified more precisely):

In[1]:= mat={{{1,2},{3,-1},{2,-4}},{{1,2},{4,-5},{6=
,-8}},{{2,-1},{-2,-3},{-4,6}}};

In[2]:= indpos=Flatten[Position[#,{u_,v_}/;v==Min[Cases[#,{=
x_,y_}->y]]]&/@mat]
Out[2]= {3,3,2}

In[3]:= MapThread[Part,{mat,indpos}]
Out[3]= {{2,-4},{6,-8},{-2,-3}}

(BTW, you have mixed ordinary parentheses and curly brackets in your exam=
ple; I corrected them).

Tomas

> Date: Fri, 15 Jan 2010 07:00:46 -0500
> From: miliotodc at rtconline.com
> Subject: [mg106544] Question about Mathematica
> To: mathgroup at smc.vnet.net
>
> Hi.  Can someone help me with the following question:
>
> I have a table of a table of number pairs:
>
> {{{1,2),(3,-1),{2,-4)},{{1,2},{4,-5},{6,-8}},{{2=
,-1},{-2,-3},{-4,6}}}
>
> How may I find the minimum second element in each sub-table?  For
> example, the first sub-table is:
>
> {{1,2},{3,-1},{2,-4}}
>
> I would like to then extract the {2,-4} element from this item.  Then
> the {6,-8} from the second sub-table, then the {-2,-3} element from=
 the
> last.
>
> Thank you,
> Dominic
>
>
 		 	   		  =


  • Prev by Date: Re: Question re I->-I
  • Next by Date: Re: Question about Mathematica
  • Previous by thread: Re: Question about Mathematica
  • Next by thread: Re: Question about Mathematica