MathGroup Archive 2007

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

Search the Archive

Re: style question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79356] Re: style question
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Wed, 25 Jul 2007 02:13:19 -0400 (EDT)
  • References: <f84jp8$qmp$1@smc.vnet.net>

On Jul 24, 3:20 am, Yaroslav Bulatov <yarosla... at gmail.com> wrote:
> 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]

SeedRandom[1];
{m1,m2} = Table[Random[Integer],{2},{1*^5},{2},{2}];
Count[Equal @@@ Transpose@{m1,m2}, True]

6175



  • Prev by Date: Re: making a fast simulation faster? Mathm. 6.0
  • Next by Date: Re: Usage Messages and Font Size in 6.0.1
  • Previous by thread: Re: style question
  • Next by thread: Re: style question