Services & Resources / Wolfram Forums
MathGroup Archive
*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
  • Subject: [mg48943] Re: faster sublist checking
  • From: Bill Rowe <readnewsciv at>
  • Date: Thu, 24 Jun 2004 05:36:22 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

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

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

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

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