Re: Wolfram free input shortcut is "cntrl ="
- To: mathgroup at smc.vnet.net
- Subject: [mg115069] Re: Wolfram free input shortcut is "cntrl ="
- From: Peter Pein <petsie at dordos.net>
- Date: Thu, 30 Dec 2010 04:10:36 -0500 (EST)
- References: <iff4b5$rav$1@smc.vnet.net>
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