Re: faster sublist checking
- To: mathgroup at smc.vnet.net
- Subject: [mg48894] Re: faster sublist checking
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Tue, 22 Jun 2004 05:31:51 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 6/21/04 at 3:49 AM, jmyers6761 at aol.com (JMyers6761) wrote: >Why is this? >A = {3, 5}; B = {1, 2, 3, 4, 5, 6, 7}; >Intersection[B, A] == Sort[A] >True >but >SublistQ[B_List, A_List] := Intersection[B, A] == Sort[A]; > >SublistQ[B, A] >False That isn't the result I get In[1]:= $Version Out[1]= 5.0 for Mac OS X (June 10, 2003) In[2]:= A={3,5};B={1,2,3,4,5,6,7}; In[3]:= Intersection[B, A] == Sort[A] Out[3]= True In[4]:= SublistQ[B_List, A_List] := Intersection[B, A] == Sort[A]; In[5]:= SublistQ[B,A] Out[5]= True 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 -- To reply via email subtract one hundred and four
- Follow-Ups:
- Re: Re: faster sublist checking
- From: DrBob <drbob@bigfoot.com>
- Re: Re: faster sublist checking