MathGroup Archive 2010

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

Search the Archive

Re: Wolfram free input shortcut is "cntrl ="


On 29.12.2010 11:59, cca at gregosetroianos.mat.br wrote:
> If we assume that all of the list elements are positive integers, then
> the following is much faster:
>
> firsts[l1_, l2_] :=  Normal[SparseArray[Automatic, {Max[l1]}, 0, {1,
> {{0, Length[l1]}, List /@ l1}, Range[Length[l1]]}][[l2]]]
>
> Example:
>
> l1 = RandomInteger[{1, 106}, 5*105];
> l2 = RandomInteger[{1, 106}, 103];
>
> In[130]:= r1 = firstPositions2[l1, l2]; // Timing
> r2 = firsts[l1, l2]; // Timing
> r1 === r2
>
> Out[130]= {2.387, Null}
>
> Out[131]= {0.109, Null}
>
> Out[132]= True
>
> Carl Woll
> Wolfram Research
>


Wow!! You are really a wizard :-)

happy new year to you and all the readers of this group,
Peter


  • Prev by Date: change of variable newbie question
  • Next by Date: Re: texture for filling?
  • Previous by thread: change of variable newbie question
  • Next by thread: Behavior of Eigenvalues and Eigensystem