[HN Gopher] Clojure Zippers (2021)
       ___________________________________________________________________
        
       Clojure Zippers (2021)
        
       Author : prydt
       Score  : 90 points
       Date   : 2025-10-23 03:51 UTC (1 days ago)
        
 (HTM) web link (grishaev.me)
 (TXT) w3m dump (grishaev.me)
        
       | 0_gravitas wrote:
       | 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!
        
       | ngruhn wrote:
       | 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         }
       | 
       | Or alternatively:                   {           left_slides:
       | List<Slide>,           current: Slide,           right_slides:
       | List<Slide>         }
       | 
       | Is it fair to call the latter a Zipper?
        
         | laszlokorte wrote:
         | Yes if List is immutable and the interface for stepping through
         | the slides ist designed accordingly
        
         | shakadak wrote:
         | Yes, although it's usually defined as:                   {
         | 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.
        
       ___________________________________________________________________
       (page generated 2025-10-24 23:01 UTC)