Talk:Search a list

From Rosetta Code
Revision as of 16:47, 26 November 2008 by Ce (talk | contribs) (What does it mean to "inately support access at an index"?)

Is it really essential that the sequence of strings is in an array? For some languages, other data structures may be more suitable. Indeed, the Common Lisp example uses a list instead of an array, and therefore doesn't conform to the current task description. Also note that the task's title speaks of a list, but the task description speaks of an array, which is sort of a contradiction. I think it would be better to allow the examples for each language to use any data structure for the sequence, as long as it's directly provided by the language or standard library. --Ce 13:33, 26 November 2008 (UTC)

I don't think the operative word is "list", but "index" instead. As long as the collection innately supports access at an index it should be fine.--Mwn3d 14:24, 26 November 2008 (UTC)
What does it mean to "inately support access at an index"? Of course for any sequence you can define access at index n by just starting at the first element and then going to the next element n times (this gives zero-based indexing, of course). Note that in Lisp, the function nth does exactly that for lists. However, for a real array, accessing the element at index n is a constant-time operation. Therefore, would you say that Lisp lists (as opposed to Lisp vectors) "inately support access at an index"? And if so, what would a sequence look like that doesn't do so?
Also, does it really matter for the task that you can access the element through that index? After all, the indexing itself isn't demonstrated. I guess the question comes down to what the task is actually intended to demonstrate. --Ce 16:47, 26 November 2008 (UTC)