You can prevent the need for mutable nodes by using an adjacency list to
represent a graph structure. In clojure this works nicely as a hash-map
from a node id to a set of connected node ids (eg for your case, a set of
parent nodes and a set of child nodes), and traversal becomes a series of
lookups.

On Sun, Jul 23, 2017 at 5:45 PM Rob Nikander <rob.nikan...@gmail.com> wrote:

> I'm translating some code from an object oriented language to Clojure. I'm
> a little confused about a tree structure I had where tree nodes have parent
> and children properties, so the structure forms cycles. I used atoms for
> those properties, so I could wire it all up. The code is clean and simple
> and I'm happy with it, except ... the things don't print in the REPL.
> (stack overflow)
>
> Are there any tricks to printing cyclical data structures in the REPL?
>
> Rob
>
> --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to