Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Operator Precedence Parser

by bart (Canon)
on Jun 11, 2006 at 16:28 UTC ( #554691=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %function = (
      sumsq => sub  { my $sum = 0; foreach(@_) { $sum += $_*$_; } return $
    +sum; },  # sum of squares
      sqrt => sub { return sqrt shift; },
    );
    
  2. or download this
        if(/\G((?i:[a-z]\w*))\s*\(/gc) {  # function '('
            my $function = $1;
    ...
            trace(sprintf "function '$function' called with %d argument%s"
    +, scalar @arg, @arg==1 ? "" : "s");
            return $function{$function}->(@arg);
        }
    
  3. or download this
    Line 29 "·sumsq(3,2+2)*sqrt(36)"
    Line 29 "sumsq(·3,2+2)*sqrt(36)"
    ...
    Line 45 "sumsq(3,2+2)*sqrt(36)·" result = 150
    150
    Stack: This value is never affected
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-12-28 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls