Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
The stupid question is the question not asked
 
PerlMonks  

Re: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6

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


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

After updating to the most current Pugs and incorporating all the ideas above, here is my final strike on the Santa Claus Perl6/Pugs Golf Apocalypse:

--- head.p6 --------------------------------------------- print*(=open@ARGS[0])[0..9] --- tail.p6 --------------------------------------------- my@l= =open@ARGS[0]; print@l[(@l>9??@l-10::0)...] --- rev.p6 --------------------------------------------- print reverse=open@ARGS[0] --- mid.p6 --------------------------------------------- my@l= =open@ARGS[0]; print@l[int((@l-1)/2)..int(@l/2)] --- wc.p6 --------------------------------------------- say*(split"",int(7e10+ +*(=open@ARGS[0])))[1..11]
It is all but nice but is is actually only 203 strokes...:-)

rg0now


Comment on Re: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6
Download Code
Re^2: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6
by audreyt (Hermit) on Mar 12, 2005 at 20:15 UTC
    Hey, why =open@ARGV[0] instead of =<> again? That will save 10 strokes per hole, bringing it to a more respectable 153...
      This is because we are ran by
      my $cmd = "pugs $scr $intmp";
      which means that we are getting the name of the file to be read as the first command line argument. But, based on my (granted, limited) understanding, =<> would read from the standard input. Am I completely missing something here again?

      rg0now

        =<> is supposed work the same as magical <> in Perl 5. To explicitly read from standard input would require =$*IN instead.
Re^2: Replaying Santa Claus Golf Apocalypse with Pugs/Perl6
by pdcawley (Hermit) on Mar 29, 2005 at 07:47 UTC
    Can open take a block yet?
    open@ARGS[0]{print..11}
    or is open ... {...} a figment of my imagination?
      Quite a strange syntax, I think. And apparently, Pugs thinks so too, because it croaks badly when I try to run your version.

      Even though, the fact that neither Pugs nor me seem to recognize this syntax, this does not mean to any extent that it is illegal. If you can recall where you met it, I can definitely make a todo_test out of it for autrijus to implement...

      rg0now

        It's a rubyish thing: Open this and then call the block for every line of the resulting file handle, closing the file at the end. I'd not be surprised if it's a hopeful figment of my imagination.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-04-17 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (444 votes), past polls