Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Magical Auto-Decrement

by Brovnik (Hermit)
on Jul 04, 2001 at 21:34 UTC ( #93899=note: print w/ replies, xml ) Need Help??


in reply to Magical Auto-Decrement

Nice try, but of course, the issue re. the boundary cases still holds, so the following

--"a" gives "z" --"a00" gives "z99" --"0" gives "9" --"aa00" gives "zz99"
give results which aren't reversible. Update: (following comment below)

Yes, you should eat the left-char on underflow, and --"a" => undef and --0 => undef.

I was going to make a point about keeping items in the right order for a sort, but of course zz++ == aaa which screws up that point. Hmmm...
--
Brovnik


Comment on Re: Magical Auto-Decrement
Download Code
Replies are listed 'Best First'.
Re: Re: Magical Auto-Decrement
by John M. Dlugosz (Monsignor) on Jul 04, 2001 at 21:40 UTC
    Looks like increment will add another character upon overflow, presumably duplicating the kind of the previous leftmost. To undo ++, the -- could eat the leftmost upon underflow. But ++ can't always be the exact opposite since it doesn't know which kind of character to add.

    I'm aware that I'm clamping on underflow. It's a snippet, not a polished module! It was done more for the challange, but if I really needed this (like the poster that inspired it), I'd have the function croak or something, if this was significant to the program.

    —John

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2015-07-31 12:10 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 (277 votes), past polls