Re: Cyclic permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg79461] Re: Cyclic permutations
- From: Peter Pein <petsie at dordos.net>
- Date: Fri, 27 Jul 2007 05:52:47 -0400 (EDT)
- References: <f7pon7$prc$1@smc.vnet.net> <f7sgu2$ss8$1@smc.vnet.net> <f84juv$qpq$1@smc.vnet.net> <200707250614.CAA23554@smc.vnet.net> <33340097.1185365315232.JavaMail.root@m35> <f89qar$5qm$1@smc.vnet.net>
DrMajorBob schrieb: > For instance... > > perms = {{a, b, c, d}, {a, c, b, d}, {b, c, d, a}}; > unsortedUnion[x_] := Tally[x][[All, 1]] > unsortedUnion[perms /. {x__, a, y___} :> {a, y, x}] > > {{a, b, c, d}, {a, c, b, d}} > > Bobby > > On Wed, 25 Jul 2007 04:27:37 -0500, King, Peter R > <peter.king at imperial.ac.uk> wrote: > ... >> (by the way I am still using version 5.1 so V6 specific methods wouldn't >> help I'm afraid) >> (* * Tally *) Tally[Except[_List],f___]:={}; Tally[lst_List]:= (* this is faster for test===SameQ *) Block[{f}, f[x_]:=(f[x]=Sequence[];{x,Count[lst,x,{1}]}); f/@lst]; Tally[lst_List,f_]:= NestWhile[ Block[{n=0}, {DeleteCases[#[[1]],x_/;And[f[#[[1,1]],x],++n>0],{1}], Join[#[[2]],{{#[[1,1]],n}}] }]&, {lst,{}},#[[1]]=!={}&][[2]];
- References:
- Re: Mathematica to .NET compiler
- From: David Bailey <dave@Remove_Thisdbailey.co.uk>
- Re: Mathematica to .NET compiler