Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

The arbitrary operator maker

by jimt (Chaplain)
on Nov 22, 2006 at 19:14 UTC ( #585598=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    
    sub multi_add {
    ...
    
    my $result = multi_add(3,4,5);
    
  2. or download this
    
    {
    ...
      }
    }
    
  3. or download this
    
    my $add_3_things = arbitrary_operator_maker('+', 3);
    ...
    
    #etc.
    
  4. or download this
    
    my $add_3_things = arbitrary_operator_maker('+', 3);
    ...
      $_[0] ^ $_[1] ^ $_[2] ^ $_[3] ^ $_[4]
    }
    
  5. or download this
    
    my $op = '+';
    ...
    and_maker 5 elements dispatched:  4 wallclock secs ( 2.95 usr +  0.01 
    +sys =  2.96 CPU) @ 337837.84/s (n=1000000)
    multi_add 5 elements:  3 wallclock secs ( 2.53 usr +  0.01 sys =  2.54
    + CPU) @ 393700.79/s (n=1000000)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://585598]
Approved by Corion
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-07-05 13:21 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 (67 votes), past polls