Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Adding 2 + 2

by roboticus (Canon)
on Jan 31, 2007 at 03:53 UTC ( #597495=note: print w/ replies, xml ) Need Help??

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%        --
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-09-20 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls