Re: Re: faster sublist checking
- To: mathgroup at smc.vnet.net
- Subject: [mg48917] Re: [mg48894] Re: faster sublist checking
- From: DrBob <drbob at bigfoot.com>
- Date: Wed, 23 Jun 2004 02:51:17 -0400 (EDT)
- References: <200406220931.FAA10282@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
>> sublistQ[x_List, y_List] := Intersection[x, y] != {} That CLEARLY doesn't test whether one list is a sublist of the other. Bobby On Tue, 22 Jun 2004 05:31:51 -0400 (EDT), Bill Rowe <readnewsciv at earthlink.net> wrote: > 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 > > -- DrBob at bigfoot.com www.eclecticdreams.net/index.html
- References:
- Re: faster sublist checking
- From: Bill Rowe <readnewsciv@earthlink.net>
- Re: faster sublist checking