>
> Why does `alter-var-root` here seem to succeed, but have no effect?
What you want is:
(set! *print-level* 2)
But, this will not work 100% of the time, and sometimes you might want
alter-var-root.
Here's the trick. *print-level* is a dynamic Var. Alter-var-root only
changes the root
One important thing to be aware of that I should have mentioned when
suggesting the adjacency list solution is the rationale for using that
representation. When you put atoms in the nodes of your data structure,
it's no longer an immutable data structure and you lose the usage patterns
that
I think in my case here the easiest thing will be to remove the cycles, but
still I'd like to understand a couple things...
On Sunday, July 23, 2017 at 10:12:46 PM UTC-4, Didier wrote:
>
> I'm not sure I can fully help without you explaining more what you're
> doing. It sounds like you've got a
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
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
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