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