Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: TIMTOWTDI/golf - counting backwards

by Juerd (Abbot)
on Jan 28, 2002 at 21:48 UTC ( [id://142125]=note: print w/replies, xml ) Need Help??


in reply to TIMTOWTDI/golf - counting backwards

Here's my first _serious_ try ;) [depends on ord($/) to be 10]

including command line:
# 1 2 3 #2345678901234567890123456789012345678 perl -le'print-!$|*$a+++ord$/for a..j'
Generic Perl (needs $/):
# 1 2 3 #234567890123456789012345678901 print-!$|*$a+++ord$/,$/for a..j

So far, I beat japhy by 2 :)
Superior to me is chipmunk, who didn't only spot my mistake in the root of this thread, but also has a version that's 3 characters shorter than mine.

2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Replies are listed 'Best First'.
Re (tilly) 2: TIMTOWTDI/golf - counting backwards
by tilly (Archbishop) on Jan 28, 2002 at 22:05 UTC
    Hrm, and I didn't get any notice for having another solution that is as short as your function, and having one that is 1 better on the command line?

    Guess I will have to improve then.

    #23456789_123456789_123456789_12345 perl -le'$x=@_=a..j;print$x--for@_' sub f { #23456789_123456789_12345678 $x=@_=a..j;print$x--.$/for@_ }
    UPDATE
    The answer to the question is "tradition". :-)

    UPDATE 2
    jmcnamara pointed out that I was miscounting. Fixed.

      The sub more or less made me assume it takes parameters. Why do you write it as a sub when it works perfectly on its own?

      2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://142125]
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-04-25 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found