RE: Greatest element in list
- To: mathgroup at smc.vnet.net
- Subject: [mg30503] RE: [mg30474] Greatest element in list
- From: "David Park" <djmp at earthlink.net>
- Date: Fri, 24 Aug 2001 04:06:02 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Oliver, Your function needs to be applied to the list. But that doesn't quite work either because then it only picks out the first element (try Trace). So what you really need is this... list = {-1, 5, 2}; Position[#, Max[#]] & @@ {list} {{2}} You could also define a routine this way... maxposition[list_] := Module[{elem = Max[list]}, Position[list, elem]] list // maxposition {{2}} David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > From: Oliver Friedrich [mailto:oliver.friedrich at tz-mikroelektronik.de] To: mathgroup at smc.vnet.net > > Hi, > > what's the best way to get the position of the greatest number in list of > reals? I've tried > > Position[#,Max[#]]&list > > but surprisingly, it doesn't work all the time, sometimes it returns an > empty list. How is that, because a theorem says that a non empty > set of real > numbers must have at least one biggest element. So Max[#] can't be empty. > > Any solutions ? > > Oliver Friedrich > >