"Randy W. Sims" <ml-ruby / thepierianspring.org> schrieb im Newsbeitrag news:414EEA6D.3050105 / thepierianspring.org... > trans. (T. Onoma) wrote: > > On Monday 20 September 2004 09:52 am, Randy W. Sims wrote: > > > >>All enumerable objects don't neccessarilly have a meaningful concept of > >>an index. Eg. sets, multisets. Enumerable and Indexable are two > >>different things, though Indexable extends Enumerable. > > > > > > Main Entry: enu·mer·a·ble > > Pronunciation: i-'n(y)üm-r&-b&l, -'n(y)ü-m&- > > Function: adjective > > : DENUMERABLE > > > > Main Entry: de·nu·mer·a·ble > > Pronunciation: di-'n(y)ü-m&-r&-b&l > > Function: adjective > > : capable of being put into one-to-one correspondence > > with the positive integers > > > > So "index" must mean this corresponding integer. I would argue that sets and > > hashes are not technically enumerable, because they're elements can not be > > accessed as a _function_ of the index, i.e. one-to-one correspondence. No. You *can* enumerate all elements (or all pairs) in a Hash. > > Perhaps separate Collectable and Indexable modules would be preferable. > > hmm, I guess in the current context I think of enumerable as meaning > iteratable, i.e. you can start at one element and "move" through the > entire collection, visiting each element only once while visiting every > element of the collection. This implies nothing about the ordering of > the list; subsequent enumerations could (but probably wouldn't) produce > a different ordering. (i.e. a file entry may appear as the first element > through one enumeration, but as the third entry during another enumeration.) > > Indexable, OTOH, would be the property which allows accessing a > particular element by positional or named access. Totally agree up to here. > Everything that is indexable is also enumarable, but not vice versa. I think those concepts are orthogonal. As an example, you can view the sin function as indexable but I doubt you'd call it enumerable (although technically you could do that becaus Float numbers are really rational numbers and not real numbers). > Sets, multisets, directory listings are enumerable, but not indexable. I agree with sets and multi sets, but one could argue that dir listings have an order and thus can be indexed. > Arrays, hashes, are both enumerable and indexable. Si. > Enumerable is probably not the right word, but it is what is currently > being used for the concept of iteratable. I find it perfectly suited. Kind regards robert