MathGroup Archive 2004

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

Search the Archive

Re: Label of Max[list]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50201] Re: Label of Max[list]
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Fri, 20 Aug 2004 04:57:46 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <cg20iv$os6$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

wehMax2[lst_] :=
  Module[{mm = Max[lst]},
    k = Position[lst, mm];
    {mm, k[[1]]}
    ]

should be a bit faster :-)

Regards
  Jens

"Dr. Wolfgang Hintze" wrote:
> 
> Is there a standard function providing beside the maximum of a list also
> the label(s) of the maximum?
> 
> My solution is this
> 
> In[23]:=
> wehMax[li_] := {m = Max[li], Select[Range[Length[li]],
>      li[[#1]] == m & ]}
> 
> In[24]:=
> li = Table[Random[], {100}];
> 
> In[25]:=
> wehMax[li]
> 
> Out[25]=
> {0.9963517693166272, {89}}
> 
> Is there a better one?
> 
> Any hint appreciated.
> 
> Wolfgang


  • Prev by Date: Comparison of Mathematica on Various Computers
  • Next by Date: Re: Label of Max[list]
  • Previous by thread: Re: Label of Max[list]
  • Next by thread: Re: Label of Max[list]