Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by Tomte (Priest)
on Jul 01, 2003 at 16:10 UTC ( #270521=note: print w/ replies, xml ) Need Help??


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

To get it, try this:

while(<DATA>) { chomp; $erg = b262b10($_); # scalar context is important! print $erg, "\n"; } # equivalent to # sub b262b10{()=a..lc pop} # but with explaining output sub b262b10{@_=a..lc pop; print join " ", @_, "\n";@_} __DATA__ A Z AA AZ BA ZZ AAA ZBA __END__ # without the debug-output: 1 26 27 52 53 702 703 17629

regards,
tomte


Hlade's Law:

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


Comment on Re: Re: Re: Re: Re: Alpha base-26 to base-10... (golf)
Download Code
Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Alpha base-26 to base-10... (golf)
by John M. Dlugosz (Monsignor) on Jul 01, 2003 at 18:04 UTC
    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.

      I may be mistaken, but I read it the way, that the pop delivers the scalar parameter for lc, (replace it with shift, the result is the same).

      the basic is that you get a list of all values between a and the parameter, evaluated in scalar-context (I had this wrong at first :-), you get the length of the list, which is of course the decimal representation.

      regards,
      tomte


      Hlade's Law:

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2015-07-31 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (280 votes), past polls