Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Things I have learnt

by leriksen (Curate)
on Oct 22, 2004 at 05:01 UTC ( #401375=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @output = sort @input; # default sort using eq to compare values
    my @output = sort {$a <=> $b} @input; # numeric sort
    my @output = sort some_func @input; # custom algorithm
    
  2. or download this
    #!/usr/bin/perl -w
    
    ...
        return fib($val - 1) + fib($val - 2);
    }
    print "called $calls times - fib calls $fibcalls\n";
    
  3. or download this
    cd /home/le6303/src/perl/
    /usr/bin/perl -w "/home/le6303/src/perl/lister.pl" 
    called 9 times - fib calls 150
    
  4. or download this
    #!/usr/bin/perl -w
    
    use strict;
    ...
    
    use Data::Dumper;
    print Dumper \@output;;
    
  5. or download this
    cd /home/le6303/src/perl/
    /usr/bin/perl -w "/home/le6303/src/perl/subber.pl" 
    $VAR1 = [
    ...
              10,
              12
            ];
    
  6. or download this
    my @output = sort {$a <=> $b} map {fib($_)} @input;
    
  7. or download this
    #!/usr/bin/perl -w
    
    use strict;
    ...
    print "called $calls times - fib $fib_calls\n";
    use Data::Dumper;
    print Dumper(\@output);
    
  8. or download this
    cd /home/le6303/src/perl/
    /usr/bin/perl -w "/home/le6303/src/perl/lister.pl" 
    called 9 times - fib 58
    ...
              8
            ];
    
  9. or download this
    my @output =  map {[$_, fib($_)]} @input;
    
  10. or download this
    cd /home/le6303/src/perl/
    /usr/bin/perl -w "/home/le6303/src/perl/lister.pl" 
    $VAR1 = [
    ...
                8
              ]
            ];
    
  11. or download this
    my @output = map {$_->[0]}              # extract just the original
                                            # value from the tuple
    ...
                 map {[$_, some_func($_)]}  # create (value, computed)
                                            # tuples
                 @input;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2015-07-08 04:24 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 (94 votes), past polls