MathGroup Archive 2008

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

Search the Archive

Tally

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86888] Tally
  • From: "Armen Kocharyan" <armen.kocharyan at gmail.com>
  • Date: Tue, 25 Mar 2008 01:16:35 -0500 (EST)

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



  • Prev by Date: Re: Counting nonzeros
  • Next by Date: Re: Counting nonzeros
  • Previous by thread: Re: Color Options for PlanarGraphPlot
  • Next by thread: Re: Tally