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: [mg48943] Re: faster sublist checking
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Thu, 24 Jun 2004 05:36:22 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 6/23/04 at 2:51 AM, drbob at bigfoot.com (DrBob) wrote:

>>>sublistQ[x_List, y_List] := Intersection[x, y] != {}

>That CLEARLY doesn't test whether one list is a sublist of the
>other.

Oops.. You are right. But the point remains, it isn't necessary to do a Sort.

The following should have the same result

sublistQ[x_List, y_List] := Length@Intersection[x, y] == Length@y

as the code from the original poster, i.e.,

SublistQ[B_List, A_List] := Intersection[B, A] == Sort[A];

--
To reply via email subtract one hundred and four


  • Prev by Date: Periodic Table of Elements (Chemistry)
  • Next by Date: Named Patterns in Switch
  • Previous by thread: Re: faster sublist checking
  • Next by thread: RE: Re: faster sublist checking