Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Adding 2 + 2

by roboticus (Chancellor)
on Jan 31, 2007 at 03:53 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://597495]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-24 22:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found