Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Just another Perl shrine
 
PerlMonks  

Re: Is Perl less compact than Ruby? (Kind of competition)

by jynx (Priest)
on Feb 19, 2002 at 19:03 UTC ( #146424=note: print w/ replies, xml ) Need Help??


in reply to Is Perl less compact than Ruby? (Kind of competition)


As for that last section,

In my testing it seems to work with the following change (saving 4 more characters):

/i/&&w+($_=getc)?ord:-1 # goes to: /i/&&w(ord getc|-1)
jynx

update: take out the parens on that up there:

/i/&&w ord getc|-1
for another 1 char savings...


Comment on Re: Is Perl less compact than Ruby? (Kind of competition)
Select or Download Code
Re: Re: Is Perl less compact than Ruby? (Kind of competition)
by dragonchild (Archbishop) on Feb 19, 2002 at 19:15 UTC
    /i/&& w ord getc||-1
    You forgot a '|'. That brings us to 306. :-)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


      Reason: (jynx) this is a duplicate, please delete.

      For more information on this node visit: this


      my testing has been limited,

      i've only been using hello.eta and hello2.eta, but using | seems to be equivalent to || there. i tested both ways and they seem to work okay on the two hello programs. did your tests come out differently? if so, which programs should i be testing with (that is, which are more indicative of a real ETA program?)

      As for the tic-tac-toe program, no matter which of the recent incarnations of the perl program i try, it seems to hang after i've given it input. does it just take a really long time or is it still running?

      jynx

        Use the tic-tac-toe program referenced in the root node.

        ------
        We are the carpenters and bricklayers of the Information Age.

        Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

        'i' is input operator of language, it must push on stack ascii code or -1 on eof.

        ord getc||-1 is excellent, although it's makes impossible to input NULL charaster. Again it's nice question of compatibility that I'm giving up to judge. It will be considered as cheating for sure.

        Update: oops, looks like previous version is also lame here (update2: not!)

        Update2: some perl black magic here:

        • zero is false but "\0" is true.
        • contrary to perlop doc's operator precedence, "ord getc||-1;" means "ord(getc)||-1" not "ord(getc||-1)".

        Update3: Second claim is lying, see "perldoc perlop/named unary operators"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2014-04-24 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (565 votes), past polls