From: David Vallner Date: 2006-01-15T02:41:43+09:00 Subject: Re: Range#member? Oddity On Sat, 14 Jan 2006 17:03:59 +0100, Stefan Walk wrote: > ara.t.howard@noaa.gov wrote: >> On Sat, 14 Jan 2006, Stefan Walk wrote: but enumerable means neither >> monotonically increasing nor finite. so that a >> range includes enumerable means only that one may start, but perhaps >> never >> finish, to count the elements in the range. i think this is accurate >> isn't >> it? >> cheers. >> -a > > Enumerable means that you can map the natural numbers to your set in an > invertable way, and that's not possible for ranges of real numbers. > Being enumerable means the possibility of a "succ" operation, and > therefore of traversing the whole set with "each" (which may take > infinite time). Being enumerable implies a working each, now try > (1.0..2.0).each... > > Regards, > Stefan > There's nothing wrong with enumerating ranges, you can well have intervals of natural numbers or other countably infinite sets. Bounded intervals of countable or countably infinite sets are finite sets and may be (not necessarily though) enumerated in order using the successor operation, which exists if the elements of the interval are well-ordered. It's not exactly an edge case, and distinguishing between ranges with finite and infinite element counts The issue with strings is that their ordering does _not_ make them such a well-ordered countably infinite set. Because strings are compared using textual comparison, as was already noted in this thread, for every two given strings, there exists an infinite amount of strings between them. For the sake of completion, strings in fact _are_ a countably infinite set, but their ordering doesn't respect any mapping of strings to natural numbers. Given this, the string successor operation doesn't even make sense from the mathemathical point of view. It is in this context defined ad hoc, and it's usefulness lies in contexts of text processing. Using a string Range is a convenient shortcut, but it's a _hack_. Nothing more, nothing less. Strings don't have a solid foundation for use in maths. If you expect strings to behave as numbers, you're wrong, they're not supposed to, any bugs are your fault, not the fault of the Ruby core API. Moan and suffer. David Vallner