Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Maximum in a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97246] Re: Maximum in a list
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Mon, 9 Mar 2009 01:04:38 -0500 (EST)
  • References: <gp07ul$l0o$1@smc.vnet.net>

Hi,

>  Suppose a list
> 
> mylist={{1,2},{3,4},{8,3}}
> 
> I would like to extract the element {i,j} of mylist for which j is max
> (here, it is the second one {3,4}).
> 
> Somebody could help me, please?

yes, and I'm sure I'm not the only one :-). Here is one possibility:

Extract[mylist, Ordering[mylist, 1, #1[[2]] >= #2[[2]] &]]

I hope if you look up the documentation for Ordering the rest should be
easy enough to understand...

hth,

albert


  • Prev by Date: Re: Maximum in a list
  • Next by Date: Re: Careless use of Scaled leads to hard crash in V7
  • Previous by thread: Re: Maximum in a list
  • Next by thread: Re: Maximum in a list