Re: Hierarchical logs

2012-02-15 Thread jweiss
Unfortunately it doesn't call the functions/macros that the pprint code says are meant for custom dispatch: pprint-logical-block pprint-newline pprint-indent etc Wish I could find an example of those being used in a custom dispatch, I made a lame attempt and for some reason my custom dispatch pri

Re: Hierarchical logs

2012-02-15 Thread Kevin Downey
https://gist.github.com/1314616 is a small example of a custom dispatch, doesn't do custom indenting though On Tue, Feb 14, 2012 at 6:33 PM, jweiss wrote: > It occurred to me that ultimately what I want is just a pretty-printed > output that I can put on a webpage and apply syntaxhighlighter to.

Re: Hierarchical logs

2012-02-14 Thread jweiss
It occurred to me that ultimately what I want is just a pretty-printed output that I can put on a webpage and apply syntaxhighlighter to. I should be able to use a custom pprint dispatch to take this [[(+ 5 (- 4 2 (* 9 3)) (* 5 (+ 6 3))) nil] [(- 4 2 (* 9 3)) nil] [(* 9 3) nil] [27 true] [-25

Re: Hierarchical logs

2012-02-14 Thread jweiss
Thanks, Alan, The solution I used looks exactly like yours: (defn mktree [vz [i out?]]   (if out?     (-> vz (zip/append-child i) zip/up )     (-> vz (zip/append-child [i]) zip/down zip/rightmost))) (defn as-tree [tracelist]   (zip/root (reduce mktree (zip/vector-zip []) tracelist))) Thinking a

Re: Hierarchical logs

2012-02-13 Thread Jon Seltzer
I'm not sure I'm getting your data example (seems like there are some characters missing or out of place) but this might be what you're looking for: user=> (def stuff [['(+ 1 (- 5 2)) nil] ['(- 5 2) nil] [3 true] [4 true]]) #'user/stuff user=> (vec (for [m stuff] (vec (butlast m [[(

Re: Hierarchical logs

2012-02-12 Thread Alan Malloy
I toyed with some simple ways of doing this, but I don't think any of them will actually work out. I think the advice you got in #clojure to use zippers is probably correct. Here's a sketch I bashed out that seems to do roughly what you want: https://gist.github.com/1807340 (I took the liberty of w