Re: faster sublist checking
- To: mathgroup at smc.vnet.net
- Subject: [mg48951] Re: faster sublist checking
- From: Marcus Stollsteimer <marcus314 at yahoo.com>
- Date: Fri, 25 Jun 2004 02:58:15 -0400 (EDT)
- References: <cb8vkr$ack$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Bill Rowe wrote: > A couple comment on your function SublistQ. It isn't necessary to > use sort since > > In[6]:= > sublistQ[x_List, y_List] := Intersection[x, y] != {} > > In[7]:= > sublistQ[A,B] > > Out[7]= > True ?????????????? In[1]:= A={1,10};B={1,2,3,4,5}; In[2]:= sublistQ[x_List,y_List]:=Intersection[x,y]\[NotEqual]{} In[3]:= SublistQ[lst_List,sub_List]:=Intersection[lst,sub]\[Equal]Sort[sub] In[4]:= sublistQ[B,A] Out[4]= True In[5]:= SublistQ[B,A] Out[5]= False -- Sometimes the delete key is your greatest friend. -- Steve Martin