I'm not sure I can fully help without you explaining more what you're doing. It sounds like you've got a collection or container type which has an implementation of print that loops over its elements, and calls print on them. So if you have a cycle, the print will go on forever until memory runs out.
If you're using a standard type, you might be able to limit *print-level* <https://clojuredocs.org/clojure.core/*print-level*>. Most Clojure collections will limit how deep they print based on the value of this global dynamic Var. If you want a solution that prints the full graph starting from any node, you'll have to define a custom implementation of print-method <https://clojuredocs.org/clojure.core/print-method> which does a traversal of the graph and stops at cycles. The traversal you'll need to implement yourself. Print-method is only there to allow you to override the function used to print, for a specific type. You could also look into using an existing graph library, like Loom <https://github.com/aysylu/loom>. I believe it will print itself properly already. On Sunday, 23 July 2017 17:45:04 UTC-7, Rob Nikander 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.