I would like to implement an algorithm that works on trees (n-ary trees) 
where each node is a complex type. Aside from the usual tree traversals I 
will need to be able to access the parent of a node.
Performance is important since the algorithm is going to traverse the tree 
several times and update the nodes.  I am wondering if a purely functional 
approach is better than using side effects.

I tried a purely functional approach with zippers but ran into some trouble 
with the zipper API. I also think I will would have performance problems 
too as there is a lot of bookkeeping in a zipper (paths, parents associated 
with a loc).

I looked into this nice document 
https://github.com/Prismatic/eng-practices/blob/master/clojure/20130926-data-representation.md
 to 
help me choose the right data structure.
When maximum efficiency is important they suggest defrecord, deftype or 
reify.
If I go for an imperative implementation it seems like deftype to represent 
the tree nodes would work well since it allows for mutable fields.

Any advice on choosing the right data structure and whether to use 
a functional or imperative implementation is appreciated.

Thanks.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to