MathGroup Archive 2005

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

Search the Archive

Re: the faster way to find repeated sublists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60944] Re: [mg60923] the faster way to find repeated sublists
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Tue, 4 Oct 2005 04:16:45 -0400 (EDT)
  • References: <200510040524.BAA17873@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 4 Oct 2005, at 14:24, giampiero wrote:

> i'm newbie
> with a stupid problem
>
> a function for find repetead sublist in faster way
>
> ex
> f[{1,2,1,2,1,2},{1,2}]-> True cause {1,2} is repated three times
> f[{1,2,3,1,2,3},{1,2,3}]-> True cause {1,2,3} is repeated two times
> f[{1,2,1,2,3},{1,2}]->False cause after two {1,2} there is another
> symbol.
>
> True if the second list in containes many times exactly in first list
> False otherwise.
>
>
> bye everyone and sorry for my stupidity.
>
> giampiero
>
>

For example:

f[l_, m_] := With[{p = Length[m]}, If[Mod[Length[l], p] ­ 0, False,
     Complement[Partition[l, p], {m}] == {}]]

Andrzej Kozlowski


  • Prev by Date: Re: Import-Function buggy in Version 5.2 ?
  • Next by Date: Re: mole units
  • Previous by thread: the faster way to find repeated sublists
  • Next by thread: Re: the faster way to find repeated sublists