Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: (almost) foldl

by Grimy (Pilgrim)
on Jun 08, 2011 at 21:10 UTC ( [id://908783]=note: print w/replies, xml ) Need Help??


in reply to Re^2: (almost) foldl
in thread (almost) foldl

Nice! But print eval join "+", ("1e", 6) yields 1000000, whereas my aforementioned solution: print sub {eval 'pop(@_)+' x ($#_ + 1) . '0';}->("1e", 6); prints the expected result, 7. Ok, ok, I'm quibbling.

Replies are listed 'Best First'.
Re^4: (almost) foldl
by BrowserUk (Patriarch) on Jun 08, 2011 at 21:17 UTC
    Ok, ok, I'm quibbling.

    Then add a couple of extra spaces :)

    say eval join' + ','1e',6;

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      print eval join' + ','1e',6;

      Bareword found where operator expected at (eval 1) line 1, near "1e" (Missing operator before e?)

      Did this actually test it, or is it because I'm running Perl 5?

      Anyway, print eval join'+0+','1e',6; works okay. Plus, the "+0+" looks nice.

        The point is that '1e' is not a valid number in Perl, so your answer of 7 is at best flawed.

        C:\test>perl -Mstrict -wE"say 0+'1e'" Argument "1e" isn't numeric in addition (+) at -e line 1. 1

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-29 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found