MathGroup Archive 2004

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

Search the Archive

Re: Label of Max[list]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50196] Re: [mg50186] Label of Max[list]
  • From: János <janos.lobb at yale.edu>
  • Date: Fri, 20 Aug 2004 04:57:33 -0400 (EDT)
  • References: <200408191028.GAA22901@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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]