81 points | by prydt 2 days ago ago
4 comments
I'm not sure if I get it. But I don't know Clojure syntax too well. Say I want to represent a slideshow state. I could do it with
{ slides: List<Slide>, current_index: Int }
{ left_slides: List<Slide>, current: Slide, right_slides: List<Slide> }
Yes, although it's usually defined as:
{ slides_shown: List<Slide>, slides_left: List<Slide> }
Yes if List is immutable and the interface for stepping through the slides ist designed accordingly
I've been using Clojure for a few years now and zippers have always been a blindspot (had no idea even _when_ they would be useful), this is a remarkable tutorial!
I'm not sure if I get it. But I don't know Clojure syntax too well. Say I want to represent a slideshow state. I could do it with
Or alternatively: Is it fair to call the latter a Zipper?Yes, although it's usually defined as:
Where the head of slides_left is the current slide. Pretty much any recursive data structure can be derived into a zipper.Yes if List is immutable and the interface for stepping through the slides ist designed accordingly
I've been using Clojure for a few years now and zippers have always been a blindspot (had no idea even _when_ they would be useful), this is a remarkable tutorial!