Algorithm::BestChoice

Choose the best
Download

Algorithm::BestChoice Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Robert Krimen
  • Publisher web site:
  • http://search.cpan.org/~rkrimen/

Algorithm::BestChoice Tags


Algorithm::BestChoice Description

Choose the best Algorithm::BestChoice is a Perl object similar to a hash, except it returns a result based on a given key AND relative ranking. That is, you can associate multiple values with a single key, and differentiate them by using a rank (or weight).SYNOPSIS # Find my favorite food based on color my $chooser = Algorithm::BestChoice->new; $chooser->add( match => red, value => cherry, rank => 1 ) $chooser->add( match => red, value => apple, rank => 10 ) # Like apples $chooser->add( match => red, value => strawberry, rank => -5 ) # Don't like strawberries $chooser->add( match => purple, value => grape, rank => 20 ) # Delicious $chooser->add( match => yellow, value => banana ) $chooser->add( match => yellow, value => lemon rank => -5 ) # Too sour my $favorite; $favorite = $chooser->best( red ) # apple is the favorite red $favorite = $chooser->best( ) # grape is the favorite among red, yellow, and purple Requirements: · Perl


Algorithm::BestChoice Related Software