4

After a few days of trying to wrap my brain around zippers, I think I finally understand how to create them from sequential data.

However, after searching for a few days, I can't seem to find any resources on how convert a zipper into something else. Basically, I want to convert some data into a format that I can pass to Hiccup to generate some HTML.

Are there any good resources on what I should be doing to convert a zipper tree into a different data structure?

Sean Hagen
  • 752
  • 10
  • 30

1 Answers1

2

I think you have it backwards, but that is a good thing. The way to use zippers is to create a zipper that works for your datastructure, not the other way around. Hickory is an excellent example. This is a good example for a zipper that uses maps instead of sequences.

Community
  • 1
  • 1
mac
  • 9,885
  • 4
  • 36
  • 51
  • Hrmm. I used a zipper because I figured it was a fast way to convert 10,000+ serial records ( database query results that have a parent_id to identify the parent ) into a tree structure so I could then use Hiccup ( or any templating system, really ) to turn that tree into HTML. Is there a speedy way to do that -- possibly using group-by or something? – Sean Hagen Nov 04 '15 at 07:44
  • Why not convert db records to hiccup directly without zippers? `(html (apply vector :ul (map #(vector :li (:name %)) db-records)))` – edbond Nov 04 '15 at 08:16
  • Because I want the db records to show up as nested comments ( Reddit-style ) rather than just a single stream -- or will that (apply vector &) handle turning them into a tree structure? – Sean Hagen Nov 04 '15 at 18:39