Bizarre Range behavior

Yukihiro M. wrote:

Indeed. The issue is that it’s not easily distinguishable whether
a sequence using #succ from a string reaches to another, or not.
If there’s affordable scheme to implement, I’d love to check in.

My original reaction to this was that the succ rules may be complicated
but they are deterministic, so it should be possible to create an
algorithm that tells you if one string is “reachable” from another
without actually stepping through all succ values.

But the more I look into this the more I realize how complicated the
succ rules are. A character’s succ is determined not only by that
character but also by the other characters in the string:

“a-”.succ
=> “b-”

“–”.succ
=> “-.”

@_@

On Wed, Aug 19, 2009 at 10:27 PM, Daniel DeLorme[email protected]
wrote:

Indeed. The issue is that it’s not easily distinguishable whether
a sequence using #succ from a string reaches to another, or not.
If there’s affordable scheme to implement, I’d love to check in.

While investigating this I came across:

“\0019”.succ
=> “\00110”

I expected the result to be “\0020”; is that a bug?

I don’t think so, the octal escape is ‘eating’ the “1” and leaving “9”
to succ to “10”:

$ ruby -v -e ‘p “\0019”.succ’
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\00110”

$ ruby -v -e ‘p “\019”.succ’
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\00110”

$ ruby -v -e ‘p “\19”.succ’
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\00110”

$ ruby -v -e ‘p “\1”.succ’
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\002”

$ ruby -v -e ‘p “\119”.succ’
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\t10”

$ ruby -v -e ‘p “\0119”.succ’
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\t10”

$ ruby -v -e ‘p “\00119”.succ’
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\00120”

$ ruby -v -e “p ‘\0019’.succ”
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\0020”

$ ruby -v -e “p ‘\00 19’.succ”
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\00 20”

$ ruby -v -e ‘p “\01 19”.succ’
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
“\001 20”