Re: 'in' for plain arrays?

2010-12-03 Thread Ali Çehreli
spir wrote: On Thu, 02 Dec 2010 08:54:43 -0800 Ali Çehreli acehr...@yahoo.com wrote: bearophile wrote: Pelle M.: It doesn't exist for performance reasons, I think. It's not a matter of performance. Walter thinks that in on AAs searches on keys. And the keys of a dynamic

Re: 'in' for plain arrays?

2010-12-02 Thread Pelle Månsson
On 12/02/2010 01:07 PM, spir wrote: Hello, Is there an equivalent of 'in' for (non-associative) arrays? Cannot find any 'contains' function. (Wouldn't it be nice to have in work for all arrays? What is the reason why it only works with AAs?) Denis -- -- -- -- -- -- -- vit esse estrany ☣

Re: 'in' for plain arrays?

2010-12-02 Thread bearophile
Pelle M.: It doesn't exist for performance reasons, I think. It's not a matter of performance. Walter thinks that in on AAs searches on keys. And the keys of a dynamic array are its indices. And searching for indices in a dynamic array is not so useful. Therefore no in for dynamic/static

Re: 'in' for plain arrays?

2010-12-02 Thread bearophile
It's not a matter of performance. Well, it's also a matter of performance. The in done on arrays is a linear search and I think Andrei thinks that in must be sublinear instead. Bye, bearophile

Re: 'in' for plain arrays?

2010-12-02 Thread Ali Çehreli
bearophile wrote: Pelle M.: It doesn't exist for performance reasons, I think. It's not a matter of performance. Walter thinks that in on AAs searches on keys. And the keys of a dynamic array are its indices. And searching for indices in a dynamic array is not so useful. Therefore no in

Re: 'in' for plain arrays?

2010-12-02 Thread bearophile
Ali Çehreli: If 'in' were to search among the values of arrays, then it wouldn't have the same meaning with AAs. But it's useful and the different semantics is very easy to remember and use. Bye, bearophile