Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Tally

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86942] Re: Tally
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 27 Mar 2008 08:15:24 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <fsa5eq$adg$1@smc.vnet.net> <fsd6n7$9gh$1@smc.vnet.net>

Jean-Marc Gulliet wrote:
> Armen Kocharyan wrote:
> 
>> 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?
> 
> 
> Although this does not answer your question, writing your expression as 
> follows should help investigating its behavior (assuming, of course, I 
> have correctly understood what you try to achieve).
> 
> Dlist={{{0,1},{0,1}},{{1,0},{1,0}},{{1,0},{0,1}},{{0,1},{1,0}}};
> 
> Tally[Dlist,
>      ((#1 === #2) ||
>       (#1[[1]] === Reverse@#2[[1]] &&
>        #1[[2]] === Reverse@#2[[2]]) &)]
> 
> ==> {{{{0,1},{0,1}},1},{{{1,0},{1,0}},1},{{{1,0},{0,1}},2}}

An even more compact way of writing the test function is as follows,


     Tally[Dlist, (#1 === #2 || #1 === Reverse /@ #2 &)]


Unfortunately, it still does not solve the issue...

Best regards,
-- 
Jean-Marc


  • Prev by Date: Re: Limit[(x - Log[Cosh[x]]) SinIntegral[x], x -> Infinity]
  • Next by Date: Re: Equi-sized tick labels
  • Previous by thread: Re: Tally
  • Next by thread: Re: Tally