3 ms·
linked list is not complex for christ sake That depends on the language. If you're using something without pointers or references it's quite hard.
by onion2k 10y ago
linked list is not complex for christ sake
That depends on the language. If you're using something without pointers or references it's quite hard.
- ldarcyftw 10y agoHmm, which (general) language has no pointers or references?
- falcolas 10y agoPython. Ruby. Javascript. Lisp. Haskel (IIRC). They all use them internally, but don't tend to make them available to the programmer (usually because they aren't needed).
- gpderetta 10y agoThey have references (at least python, lisp that I know of, likely the others as well), which is enough to implement linked lists.
- falcolas 10y agoThe ability to implement linked lists != pointers and references Behind the scene, yes, every Python variable is a reference to an object. It's not addressable, however, and in the case of immutable objects (like strings), you can't modify the underlying object and keep all references pointed at that updated object.
- gpderetta 10y agoIf have references you can pretty much always implement lists. First all you do not need mutability, you can implement linked lists form immutable cons cells, second python has mutable references so implementing linked lists is trivial (the fact that some objects are in fact immutable is immaterial).
- ldarcyftw 10y agoWell, at least in Ruby and Javascript variables are references to objects and it is trivial to implement a linked list in both.