Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Re: Re: Alpha base-26 to base-10... (golf)

by bwana147 (Pilgrim)
on Jul 01, 2003 at 10:46 UTC ( #270437=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Alpha base-26 to base-10... (golf)
in thread Alpha base-26 to base-10...

sub b262b10{ () pop }


In Golf, there's no need for strict or quotes. A bareword is a string when Perl can't find an identifier with that name. So here, a is just "a", only two strokes shorter.

pop takes one argument off of @_, and since there's only one argument, it's just the same as shift. lc turns it to lower case.

.. is the range operator in list context, but the flip-flop operator in scalar context. The construct ()= forces list context. The value of a list assignment is the number of elements of the right member, even though the left value (()) is empty.

So this sub yields (in scalar context) the number of element between "a" and the string passed as argument. QED


Replies are listed 'Best First'.
Re: Re: Re: Re: Alpha base-26 to base-10... (golf)
by John M. Dlugosz (Monsignor) on Jul 01, 2003 at 15:36 UTC

    Care to explain that?

      To get it, try this:


      Hlade's Law:

      If you have a difficult task, give it to a lazy person --
      they will find an easier way to do it.

        Ah, that's lc the lower-case function, not 1c the hex representation of 28.

        But I still don't understand why you can have the following pop without a delimiter after the assignment statement. I think the purpose of the pop is to subtract one from the result.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-01-24 03:56 GMT
Find Nodes?
    Voting Booth?