You can certainly do this without zippers. Here's one simple way:

(defn skeleton 
  [tree]
  (map skeleton (filter seq? tree)))

This style of recursion consumes memory proportionate to the depth of the tree, 
and will run out for enormously deep trees. But for reasonable trees it should 
be fine and I like it for its clarity.

 -Lee

On Sep 8, 2011, at 1:05 PM, octopusgrabbus wrote:

> This isn't a request to get help w/ a 4Clojure problem, and I am not 
> specifically asking for help with producing the skeleton (the tree structure 
> without the leaves) of the sequences show below, although I would be 
> appreciative of help. Instead I am asking if a solution to do this is simple 
> or requires an approach like clojure-zip. Thanks for the 4clojure group link. 
> Didn't know it existed.
> 
> (def test_data1 '(1 (2 3) ( ) (( )) :a))
> 
> (def test_data2 '(1 2 (3 4) (5 ( 6 7 8))))
> 
> (def test_dat(1 (2 (3 4)) 5 6  (7) ( )))
> 

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to