Re: faster sublist checking
- To: mathgroup at smc.vnet.net
- Subject: [mg48964] Re: faster sublist checking
- From: koopman at sfu.ca (Ray Koopman)
- Date: Fri, 25 Jun 2004 02:58:36 -0400 (EDT)
- References: <cbe7r0$rh9$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Wolf, Hartmut" <Hartmut.Wolf at t-systems.com> wrote in message news:<cbe7r0$rh9$1 at smc.vnet.net>... > [...] > Ray, > > to me your timings appear somewhat mysterious: > [...] This should clarify what's happening on my system. Maybe more recent versions implement these functions differently. In[1]:= $Version Out[1]= "NeXT 3.0 (July 11, 1997)" In[2]:= try[len_, inc_] := Block[ {B = Table[0,{len}], a = Table[1,{10}], A}, Map[(A = Join[Take[B,#], a, Drop[B,#]]; {#, Timing@MemberQ[Partition[A, Length[a], 1], a], Timing@MatchQ[A, {___,Sequence@@a,___}]})&, Range[0, len, inc]]] In[3]:= try[900, 100]] Out[3]= {{ 0,{0.078119 Second,True},{0.015654 Second,True}}, {100,{0.062395 Second,True},{0.171864 Second,True}}, {200,{0.093761 Second,True},{0.343752 Second,True}}, {300,{0.078067 Second,True},{0.484140 Second,True}}, {400,{0.093722 Second,True},{0.687520 Second,True}}, {500,{0.093732 Second,True},{0.874995 Second,True}}, {600,{0.093746 Second,True},{1.01557 Second,True}}, {700,{0.125002 Second,True},{1.21870 Second,True}}, {800,{0.109375 Second,True},{1.35875 Second,True}}, {900,{0.109367 Second,True},{1.51505 Second,True}}} In[4]:= try[9000, 1000]] Out[4]= {{ 0,{0.937479 Second,True},{0.015637 Second,True}}, {1000,{0.906122 Second,True},{14.2619 Second,True}}, {2000,{0.874563 Second,True},{29.2263 Second,True}}, {3000,{0.874677 Second,True},{43.3964 Second,True}}, {4000,{0.952819 Second,True},{58.1825 Second,True}}, {5000,{0.952546 Second,True},{72.9310 Second,True}}, {6000,{0.937124 Second,True},{87.5178 Second,True}}, {7000,{0.999475 Second,True},{101.483 Second,True}}, {8000,{1.03124 Second,True},{116.957 Second,True}}, {9000,{1.03122 Second,True},{131.086 Second,True}}}