—
> list
{ value: 0, rest: { value: 1, rest: null } }
> add(list, 2)
{ value: 0, rest: { value: 1, rest: { value: 2, rest: null } } }
> list
{ value: 0, rest: { value: 1, rest: null } }
— This shows that the add function returns a new list, while the original remains unchanged
— Thanks TRGWII for all the help 😁
— Why are you doing linked lists in JS though?
— I'm doing practice with all exercise problems of eloquent js
— Beware, this has to copy every part of the list by neccessity
— So it might be memory-intensive
— So when i was doing that i got a doubt related to that
— Of course it wouldn't have to copy other subtrees since they remain unaffected