Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

How A Function Becomes Higher Order

by Limbic~Region (Chancellor)
on Sep 16, 2005 at 15:51 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://492651]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-20 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found