From: "Randy W. Sims" Date: 2004-09-20T23:38:59+09:00 Subject: Re: Array#index block and rdetect 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. > > 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. Everything that is indexable is also enumarable, but not vice versa. Sets, multisets, directory listings are enumerable, but not indexable. Arrays, hashes, are both enumerable and indexable. Enumerable is probably not the right word, but it is what is currently being used for the concept of iteratable. Randy.