Re: When Wolfram's technical support cannot help
- To: mathgroup at smc.vnet.net
- Subject: [mg105290] Re: When Wolfram's technical support cannot help
- From: "Nasser M. Abbasi" <nma at 12000.org>
- Date: Wed, 25 Nov 2009 23:04:53 -0500 (EST)
- References: <hej3pj$d77$1@smc.vnet.net>
On Nov 25, 5:18 am, "Ant King" <mathstutor... at ntlworld.com> wrote: > Hi > > I sent this email to technical support (as I hold a premier licence) > > I am looking for a single function that will extract the cyclic part of (a) > a completely cyclic sequence and (b) an eventually cyclic sequence. So if > > data1={1,2,3,1,2,3,1,2,3,1,2,3} then cyclicpart[data1] should return {1,2,3} > > And if > > data2={5,9,11,8,1,2,3,1,2,3,1,2,3,1,2,3} then cyclicpart[data2] should also > return {1,2,3} > > And this was the reply that I got > > Here is one way to extract out the cyclic part: > > lis = Flatten[Join[Table[{1, 2, 3}, {8}]]] > > p = Position[Table[BitXor[lis, RotateLeft[lis, i]], {i, 1, 10}], > ConstantArray[0, Length[lis]]][[1]] /. {a_} -> a > lis[[1 ;; p]] > > The above however will only work for case where the list always contains > the repeated pattern. > > There is no built-in function as such that will extract out the pattern > automatically. I have filed a suggestion with our developers and you will > be notified when this suggestion gets implemented. Again, my apologies for > the delay and my thanks for your patience. > > Now I don't believe that. I think that it should be quite achievable. Anyone > got any ideas > > Thanks a lot > > Ant May be using the algorithm for finding longest repeated subsequence might help with your second case data2? --Nasser