[Omaha.pm] Evolution or devolution?

Sean Baker pbaker at omnihotels.com
Thu Dec 28 13:36:39 PST 2006


There is such a thing as maintainable code.  I guess a Schwartzian
Transform isn't all that bad.

http://en.wikipedia.org/wiki/Schwartzian_Transform

Sean Baker
Omni Hotels

-----Original Message-----
From: omaha-pm-bounces+pbaker=omnihotels.com at pm.org
[mailto:omaha-pm-bounces+pbaker=omnihotels.com at pm.org] On Behalf Of Jay
Hannah
Sent: Thursday, December 28, 2006 3:29 PM
To: omaha-pm at pm.org
Subject: [Omaha.pm] Evolution or devolution?

Here's three code snippets in 3 different chunks of code that do the
same thing... Is this progress?  :)

j



First example I found...

    my ($common_rate,$cnt);
    foreach my $rate (keys %common_rates) {
      if ($common_rates{$rate} >= $cnt) {
        next if ($rate < $common_rate);
        $common_rate = $rate;
        $cnt = $common_rates{$rate};
      }
    }


Second example I found...

   my ($highest_frequency) = reverse sort values %ratecount;
   @rates = grep { $ratecount{$_} == $highest_frequency } @rates;
   my @common = reverse sort @rates;
   return $common[0];


Code I just wrote:

   print [ sort { $common_rates{$b} <=> $common_rates{$a} } keys
%common_rates ]->[0];



http://cancerweb.ncl.ac.uk/cgi-bin/omd?query=devolution&action=Search+OM
D
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm



More information about the Omaha-pm mailing list