MathGroup Archive 2007

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

Search the Archive

Re: style question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79332] Re: style question
  • From: Peter Pein <petsie at dordos.net>
  • Date: Wed, 25 Jul 2007 02:00:36 -0400 (EDT)
  • References: <f84jp8$qmp$1@smc.vnet.net>

Yaroslav Bulatov schrieb:
> What is the recommended way of counting the number of matches in two
> lists?
> 
> The natural way would be to thread over Equal, but Equal will evaluate
> before Thread gets to it. The method below works, but somehow feels
> wrong
> 
> m1 = RandomInteger[{1}, {10^5, 2, 2}];
> m2 = RandomInteger[{1}, {10^5, 2, 2}];
> matches = Thread[temporary[m1, m2]] /. temporary -> Equal;
> Count[matches, True]
> 
> 

I would use

Count[Equal @@@ Transpose[{m1, m2}],True]

P^2


  • Prev by Date: Re: export data to spreadsheet
  • Next by Date: RE: Mathematica to .NET compiler
  • Previous by thread: Re: Re: style question
  • Next by thread: Re: style question