Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

How A Function Becomes Higher Order

by Limbic~Region (Chancellor)
on Sep 16, 2005 at 15:51 UTC ( #492651=perltutorial: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use List::Util 'max';
    my @scores = <FH>;
    my $high_score = max(@scores);
    
  2. or download this
    my $high_score;
    while ( <FH> ) {
        chomp;
        $high_score = $_ if ! defined $high_score || $_ > $high_score;
    }
    
  3. or download this
    sub gen_max {
        # Create an initial default value (or undef)
    ...
    
    # Get the return value of the anonymous sub
    my $high_score = $max->();
    
  4. or download this
    sub gen_reduce {
        my $usage = 'Usage: gen_reduce("initial" => $val, "compare" => $co
    +de_ref)';
    ...
        $maxstr->($_);
    }
    my $long_str = $maxstr->();
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://492651]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (18)
As of 2015-07-30 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls