Re: string range membership


#1

Brian,

I’d argue that it is not a bug, as there is no unique
isomorphie from strings to integers.

I have to disagree.

ruby -v -e “p((‘1’…‘10’).to_a)”
ruby 1.8.2 (2004-12-25) [i386-mswin32]
[“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”]

This shows a clear and unique mapping of the range '1'..'10' into a

set of strings.

- Warren B.

#2

On Wed, 23 Nov 2005, Warren B. wrote:

This shows a clear and unique mapping of the range ‘1’…‘10’ into a
set of strings.

but where do ‘01’, ‘001’, and ‘0001’ go? they too, are in the set of
strings.

regards.

-a


#3

Hi,

In message “Re: [BUG] string range membership”
on Wed, 23 Nov 2005 23:57:41 +0900, “Warren B.”
removed_email_address@domain.invalid writes:

|> I’d argue that it is not a bug, as there is no unique
|> isomorphie from strings to integers.
|
| I have to disagree.

For your information, member? used to iterate over items to check
membership. But since confusion between include? and member?, they
were merged. The point is Ranges are used both for ranges and
intervals. Sometimes users want it to behave like a range surrounded
by begin/end values. Sometimes they want it to behave like a set of
values, that #each produces.

I’d like to care this issue, but I haven’t know the right way to solve
it yet. Perhaps we should provide both membership method, with right
names for each. Any ideas?

						matz.

#4

On 23/11/05, Warren B. removed_email_address@domain.invalid wrote:

This shows a clear and unique mapping of the range '1'..'10' into a

set of strings.

- Warren B.

It is not unique as

ruby -e “p %w(1 10 11 100 101).map { | b | b.to_i(2) }”
[1, 2, 3, 4, 5]

is another mapping of strings to integers that is equally valid (and
would not contain ‘5’).

Brian


http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/