Thanks! This is actually kinda close to a solution that I've just
managed to come up with, though mine is somehow twice as long :).
Correct me if I'm wrong, but this could eat up the stack when parsing
a large document?  I'm totally fine with it for my current needs,
though I'm curious to see a solution that doesn't.

Thanks again!
-Joel

On Dec 1, 1:03 am, Chouser <[EMAIL PROTECTED]> wrote:
> On Sun, Nov 30, 2008 at 5:12 PM, Joel L <[EMAIL PROTECTED]> wrote:
>
> > I've hit a wall trying to work with tree like data structures,
> > specifically the xml-seq.  I want to translate clojure.xml's xml
> > representation into something close to compojure's html data
> > structure.
>
> > eg:
> >  {:tag :div :attrs {:class "foo"}
> >   :content
> >    [{:tag :h1 :attrs nil :content ["Title"]}
> >     {:tag :p :attrs nil :content ["Test"]}]}
>
> > ->
>
> >  [:div {:class "foo"} [:h1 "Title"] [:p "Test"]]
>
> This has not been deeply tested:
>
> (defn f [{:keys [tag attrs content] :as other}]
>   (if tag
>     (vec (concat [tag]
>                  (when attrs [attrs])
>                  (when-let [s (map f content)] (vec s))))
>     other))
>
> --Chouser
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to