Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6

by rg0now (Chaplain)
on Mar 12, 2005 at 16:22 UTC ( #438941=note: print w/ replies, xml ) Need Help??


in reply to Replaying Santa Claus Golf Apocalypse with Pugs/Perl6

And here is my strike at rev.p6

my@l=(open@ARGS[0]).readline(); for(@l){print pop(@l)}

Update: using the  = $filehandle operator in list context, this boils down to:

my@l==open@ARGS[0]; for(@l){print pop(@l)}

rg0now


Comment on Re: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6
Select or Download Code
Re^2: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6
by TimToady (Parson) on Mar 12, 2005 at 16:49 UTC
    I would consider it a bug that == can be parsed as = =, so you shouldn't depend on that. On the other hand, the for will not require parens, though it will require a space before the opening bracket. And @l.pop would be shorter than the function form. Then again, you eventually ought to be able to do the whole thing with
    print reverse=<>;
      You are absolutely right just about everything, you wrote, except that when golfing with Pugs, you must take into account that many things will not work as expected, or will not work at all...:-)

      For example, Pugs does not have reverse yet. And while it seems to recognize the parenless form of for, it requires an extra space not just before the loop statement, but immedaitely after it, too. So, the code takes the form:

      my@l= =open@ARGS[0]; for @l {print @l.pop}
      And this is just as long as the form with parens, but less clean.

      However, the more I see the @l.pop form, the more I like it. Thank you for pointing this out to me...

      Update: I was stupid, parenless for is working just right, as TimToady suggested, I don't know, what the hell I was messing up...:-)

      rg0now

      Indeed, and that bugs is closed, so 6.0.11 won't parse it as = =. On the other hand, :==$x stays legal and is parsed as := =$x in the absense of an user-defined :== operator, which I think is correct -- let me know if it's not. :)

      The for@l {...} form is indeed correctly parsed; no whitespace is needed before @.

      Finally, thanks to this Golf-Driven Development, nothingmuch is now implementing reverse as we speak, so 6.0.11 should be happy with print reverse=<> -- note that I shaved the trailing semicolon. Yay!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2014-09-18 22:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (125 votes), past polls