3 ms·
>What's the rationale for lists and tuples being different, and not just allowing lists to include different types? Heterogeneous lists are a pretty advanced f
by ivanbakel 6y ago
>What's the rationale for lists and tuples being different, and not just allowing lists to include different types?
Heterogeneous lists are a pretty advanced feature in the world of static typing. Since hetlists normally have to be fixed size anyways to do type-safe indexing, tuples are good enough for something like 99% of use cases.
- AlchemistCamp 6y agoIn Erlang, lists are linked lists. The fact that tuples are stored in memory sequentially is a major difference from lists.
- lpil 6y agoWhat data structure would you think of when you hear just "list"?
- qppo 6y agoList is an access pattern, like a queue or deque. Linked lists are a data representation using a couple of pointers. It's like the difference between a graph and an adjacency list or matrix. A list being a linked list is an implementation detail. At least to me. Mostly because linked lists are in general, awful ways to store data.
- lpil 6y agoIt depends on what you want to do with them. They have constant time prepending and support structural sharing, both highly desirable features in many use cases.