3 ms·
Forgive me but are linked lists common in other languages?
by pfundstein 6y ago
Forgive me but are linked lists common in other languages?
- smabie 6y agoSuper common? Main data structure in Scala, any kind of Lisp, Haskell, Erlang, etc. Linked lists are a functional programmer's goto data structure.
- pfundstein 6y agoWell that would explain why I've only encountered them in C.
- azernik 6y agoC is the only language where they're called "linked lists"; everything else just calls them "lists".
- pjmlp 6y agoNope, plenty of literature refers to them as linked lists. Here is an article about them in Modula-2, to use a language of similar age as C. https://www.modula2.org/tutor/chapter11.php https://www.modula2.org/tutor/chapter11.php
- azernik 6y agoI was being loose with the words "everything" and "only". GP comment was curious about why they've only heard about "linked lists" in a language, C, which like Modula-2 does not use them as the basic standard library collections type. When you have to implement linked lists yourself if you want to use them, you're always going to refer to them by implementation detail. In the vast majority of cases where they're used, though, it's as the fundamental standard library collection, and in that case they're usually just called Lists without telling the caller about their implementation. (This idiom is true to the point that the Python implementers feel the need to point out that CPython uses arrays to implement the list type, as they feel that this would be unexpected to users of other languages that call their basic collections type a "list".)