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

Re: Re: Re: Golf: Arbitrary Alphabetical Sorting

by merlyn (Sage)
on May 09, 2001 at 20:07 UTC ( #79141=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Golf: Arbitrary Alphabetical Sorting
in thread Golf: Arbitrary Alphabetical Sorting

Well, if it's a single "character", tr likes it. What's the problem? About the only thing that's messy is the use of a slash and dash, and I could probably hork that somehow by always mapping to an octal-ish escape.

I've reread the question three times now, and I don't see how you are defining "character" in any way other than something that tr can wrangle. If so, what's the structure of a "word" then? It's no longer a string, which would be a sequence of "characters" that tr can handle!

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Re: Re: Golf: Arbitrary Alphabetical Sorting

Replies are listed 'Best First'.
Re: Re: Re: Re: Golf: Arbitrary Alphabetical Sorting
by premchai21 (Curate) on May 09, 2001 at 20:12 UTC
    But what if the alphabet has 100 characters? Then, %m will have a through z, undef, undef, undef... as values, unless I'm missing something, which I'm pretty sure I'm not. That will lead to incorrect handling of the characters "above" 26.
Re: Re: Re: Re: Golf: Arbitrary Alphabetical Sorting
by Masem (Monsignor) on May 09, 2001 at 20:14 UTC
    In your code, you prep your translation hash %m with keys from the input alphabet, and values of a through z. What if the input alphabet was [a..z1], or [a..z0-9]? These are more than 26 characters and thus, the 27th and higher characters will have null values for their keys, and will mess up your tr-and-back transformation.
    Dr. Michael K. Neylon - || "You've left the lens cap of your mind on again, Pinky" - The Brain

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://79141]
[LanX]: new Firefox + cb sidebar do random auto expand on submit
[LanX]: probably need to start pm discussion
[LanX]: they have a constitutional referendum in turkey, kind of "do you want a dictator" and everybody opting no gets problems ...
[Corion]: LanX: Random Auto Expand?
[Corion]: LanX: Well, everybody opting "yes" will also get problems. The question is more like "Do you want problems now or problems later?"
[LanX]: and the AA had posters with a big say NO with a small "to alcohol"
[ambrus]: LanX: is it the kind of free and secret vote where there's only one box you can check?
[LanX]: no two boxes , enemies of the state are just denounced

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2017-03-27 12:18 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.