{
slides: List<Slide>,
current_index: Int
}
Or alternatively: {
left_slides: List<Slide>,
current: Slide,
right_slides: List<Slide>
}
Is it fair to call the latter a Zipper? {
slides_shown: List<Slide>,
slides_left: List<Slide>
}
Where the head of slides_left is the current slide.
Pretty much any recursive data structure can be derived into a zipper.Once for navigating a collection of deeply nested routes in a webapp, and once for navigating deeply nested xml to grab very particular data.
Both times it was pretty pleasant and nice to use.
I wouldn't reach for them in most normal situations cause they're more complicated to get right than simple looping (or `clojure.walk/prewalk`), but if you have large semi-predictable data structures, you can do cool stuff with zippers.
0_gravitas•1d ago