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: [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


  • Prev by Date: Re: multigraphics
  • Next by Date: Re: multigraphics
  • Previous by thread: RE: Re: faster sublist checking
  • Next by thread: Re: faster sublist checking