3 ms·
Another way of looking at it that's nice is that they "rewire the pointers". If a LL looks a bit like this [1] -> [2] -> [3] -> [4] -> [] where the [n] lo
by tel 11y ago
Another way of looking at it that's nice is that they "rewire the pointers". If a LL looks a bit like this
[1] -> [2] -> [3] -> [4] -> []
where the [n] location actually represents a data pointer then stepping into the zipper rearranges some of these...
[1] <- [2] -> [3] -> [4] -> []
[1] <- [2] <- [3] -> [4] -> []
To be a bit more explicit we should talk about where "we" are
* -> [1] -> [2] -> [3] -> [4] -> []
[1] <- * -> [2] -> [3] -> [4] -> []
[1] <- [2] <- * -> [3] -> [4] -> []
etc etc.
- cousin_it 11y agoTo explain stuff to imperative programmers, you need to adopt the operational perspective. Spell out what's actually in memory at any given time, what gets executed after what, where the allocations happen, what's left for the GC to pick up, etc. If you tell them that zippers "rewire the pointers", they will get rightly confused, because rewiring existing pointers is impossible in pure code. Zippers allocate new pointers instead. That's what you should say.