Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: Problem rendering fonts (?) in mathematica
  • Next by Date: Re: faster sublist checking
  • Previous by thread: Re: faster sublist checking
  • Next by thread: Re: Re: faster sublist checking