3 ms·
So in the example of the linked list, how do you add an element to the middle? I actually don't think you can make this work in a conventional sense - you'd cop
by joe_the_user 7y ago
So in the example of the linked list, how do you add an element to the middle? I actually don't think you can make this work in a conventional sense - you'd copy the whole list and lose all linked-list advantages. Instead, my impression functional programming uses list objects that appear to copy the whole list, are efficient but actually use shared memory and are mutable "behind the scenes". And sure that works but it results in one's code being a few more levels of abstraction away from what's happening with the processor.
- mangodrunk 7y agoIt seems that this implementation of a list is more useful when used like a stack. As a general list (with more operations than "pop" and "push"), not so great in terms of performance compared to one that is mutable. I did like the article and how the author writes so simply. To the author's credit, right below, they do have the section on "When you can't help it", which if you do need insertion like that and performance matters, probably best to use a mutable data structure.