MathGroup Archive 2004

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

Search the Archive

Re: Label of Max[list]


Dear Wolfgang,

I think Position is much faster than Select.  /I am not saying it is 
better /

wehMax[li_] := {m = Max[li], Select[Range[Length[li]],
      li[[#1]] == m & ]}

li = Table[Random[], {100000}];

In[7]:=
Timing[wehMax[li]]

Out[7]=
{0.7 Second,{0.999993,{76559}}}

jlmax[li_] := {Max[li], Position[li, Max[li]]}

In[9]:=
Timing[jlmax[li]]

Out[9]=
{0.09 Second,{0.999993,{{76559}}}}

My guess that Reap and Sow would be even faster.

János
------
"..because Annushka has already bought sunflower oil, and not only 
bought it, but spilled it too."
Bulgakov:  Master and Margarita


  • Prev by Date: Re: Label of Max[list]
  • Next by Date: Beware of adding 0.0
  • Previous by thread: Label of Max[list]
  • Next by thread: Re: Label of Max[list]