Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Operator Precedence Parser

by bart (Canon)
on Jun 11, 2006 at 16:28 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://554691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-25 17:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found