in reply to Re: $a++ allowed by $a-- is not ! why?
in thread $a++ allowed by $a-- is not ! why?

It depends upon which EBCDIC variant the platform was running but IIRC with Western European platforms it would be a speech mark. But I take your point.

But since the sequence is a b c d e f g h i etc. why not apply magic to the -- operation and use the numbers as Base 26.

So a decrement would of ab would become:

'ab' = (1*(25*1))+(2*(25*0)) 'ab'-- = (1*(25*1))+((2*(25*0))-(1*(25*0))) = (1*(25*1))+((1*(25*0)) = 'aa'

Then 'a'-- would always = -1 and decrements become OK with a predictable behaviour.

Replies are listed 'Best First'.
Re: Re: Re: $a++ allowed by $a-- is not ! why?
by Anonymous Monk on Sep 02, 2003 at 19:54 UTC
    Sorry, totally wrong, it should be:
    'ab' = (1*(26**1)) + (2*(26**0)) 'ab' -- = (1*(26**1)) + ((2*(26**0)) - (1*(26*0))) = (1*(26**1)) + (1*(26**0)) = 'aa'
    But ideally a string containing only alphanumerics with an alphabet in upper and lower case could be handled as a Base 62 number which would also allow decrement, because the question with the above is how does it handle numerics and upper case. Base 62 would solve that.