MathGroup Archive 2002

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

Search the Archive

Re: Pattern Matching in Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35607] Re: Pattern Matching in Lists
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 22 Jul 2002 02:11:09 -0400 (EDT)
  • References: <ah8ojs$au6$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Adding Andrzej's idea using a single rotation with correction to Carl's
latest gives a further speed up:

    w=Table[Random[Integer],{1000000}];

    (Tr[#]-Tr[BitAnd[# ,Drop[w,1]]])&[Drop[w,-1] ]//Timing

        {2.36 Second,249981}

    (Tr[w]-Tr[BitAnd[w ,RotateLeft[w]]])+
        If[w[[1]]==0&&w[[-1]]==1,-1,0]//Timing

        {1.43 Second,249981}

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565






  • Prev by Date: Problem using a loop to generate data for Point function
  • Next by Date: RE: Beep
  • Previous by thread: Re: Pattern Matching in Lists
  • Next by thread: Re: Pattern Matching in Lists