Hacker News new | past | comments | ask | show | jobs | submit login

That's true for slicing and indexes, but hopefully you can use Iterator then for basic traversal, which does this.



Yep, when iterators do the trick, they're preferable to indexing. But some algorithms (e.g., the tortoise and hare algorithm for cycle detection) explicitly require indexing.


Not necessarily – you can chain iterators and skip elements on the hare.


You're right. I was thinking exclusively of the case where you have an array whose elements themselves are indices into the same array.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: