On May 11, Paul said:

>> That sorting method does a lot of work -- that is, it does things
>> more than once.  I suggest you use a schwarztian transform, or the
>> Orcish maneuver, to increase speed.
>>   {
>>     my %cache;
>>     @new = sort {
>>       ($cache{$a}) = $a =~ /\@([^:]+)/ if not exists $cache{$a};
>>       ($cache{$b}) = $b =~ /\@([^:]+)/ if not exists $cache{$b};
>>       $cache{$a} cmp $cache{$b}
>>   } @orig;
>While this is reasonably obvious, I'd never heard it called that.
>A name always helps me remember things like that. Thanks.

Joseph Hall (author of "Effective Perl Programming") coined the term
"Orcish maneuver", because in essence, it's supposed to look like:

  $cache{$a} ||= function($a);
  $cache{$b} ||= function($b);

So it's "OR" + "cache" = "Orcish" -- pronounced the same way a reader of
Tolkien literature would say it.

Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734

Reply via email to