Re: Tally
- To: mathgroup at smc.vnet.net
- Subject: [mg86925] Re: Tally
- From: Michael Weyrauch <michael.weyrauch at gmx.de>
- Date: Wed, 26 Mar 2008 04:54:45 -0500 (EST)
- References: <fsa5eq$adg$1@smc.vnet.net>
Hello, I dont't think there is anything wrong with your code, but I know that under certain conditions Tally does not work properly. I postet a similar problem re Tally last November to Wolfram support, and I got the answer that Tally is not always working correctly. I suggest you write your own Tally function, e.g. using Sow and Reap. This works fast and perfect in my situations. Michael Weyrauch Armen Kocharyan schrieb: > Dear Group, > > I'm trying the following: > > > *Dlist = {{{0,1},{0,1}},{{1,0},{1,0}},{{1,0},{0,1}},{{0,1},{1,0}}};* > > *Tally[Dlist,(#1=== #2) \[Or] * > > * (#1[[1]][[1]]=== #2[[1]][[2]] \[And] * > > * #1[[1]][[2]]=== #2[[1]][[1]] \[And] * > > * #1[[2]][[1]]=== #2[[2]][[2]] \[And] * > > * #1[[2]][[2]]=== #2[[2]][[1]] )&]* > > > > The output is: > > *{{{{0,1},{0,1}},1},{{{1,0},{1,0}},1},{{{1,0},{0,1}},2}}* > > instead of > > *{{{{0,1},{0,1}},2},{{{1,0},{0,1}},2}}* > > > > If I remove the last member from DList > > *Dlist = {{{0,1},{0,1}},{{1,0},{1,0}},{{1,0},{0,1}}};* > > then I got a correct answer > > *{{{{0,1},{0,1}},2},{{{1,0},{0,1}},1}}.* > > > > Is anything wrong with my original code? > > > > Best regards, > > Armen > >