Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    use strict;
    ...
    print_add 2,2;
    print_add 2,2,2;
    print_add 4,8,12;
    
  2. or download this
    root@swill ~/PerlMonks
    $ ./adder_1.pl
    2 + 2 = 4
    2 + 2 + 2 = 6
    4 + 8 + 12 = 24
    
  3. or download this
    sub add {
            my $accumulator = 0;
    ...
            }
            $accumulator;
    }
    
  4. or download this
    #!/usr/bin/perl -w
    use strict;
    ...
            'Recursive' => sub { 2 == add_rec(2,2); },
            'Iterative' => sub { 2 == add_iter(2,2); }
    });
    
  5. or download this
    $ ./adder_bench.pl
                  Rate Recursive Iterative
    Recursive  79051/s        --      -48%
    Iterative 152207/s       93%        --