> Maybe you could use a parent map.
> You have a normal tree, and then you have a map where
> you can get the parent for a given node. I don't know if this
> will be too slow for your problem - it's just an idea.
I haven't thought about it, thank you. I'm going to try different
options and decid
Maybe you could use a parent map.
You have a normal tree, and then you have a map where
you can get the parent for a given node. I don't know if this
will be too slow for your problem - it's just an idea.
Kind regards Sune
On Oct 13, 6:45 pm, andrei wrote:
> How can I override print-method for a
Interesting approach. I'll keep it in mind, but for this particular
project I actually have to have mutable objects - both parents and
children must be modifyable. Also I really want to see them as
collections: closures where used everywhere in the previous version of
program, and it was very hard
Instead of using a ref, you might consider using a closure, which
seems a little more functional.
So every child would simply store a function that when called would
return the map of the parent, map you capture using a closure. This
would also reduce your printing problems because functions just
That works, thanks!
Yeah, I understand that it is not the best data structure to use. The
task is to create a tree, and it is needed to get all children and all
parents of specified node in this tree in a constant time. So, I
cannot see another way to do it except storing refs both from parents
t
You can add a :type metadata to your maps, and this can be catched by the
(type) method of multimethods.
But if you have parent -> child -> parent -> child ... relationships, I
guess that you're building a tree made of mixins of maps and refs to maps
... and indeed this should bell some rings in y
How can I override print-method for a map, defined with defstruct?
I have to create object hierarchy: one map is a parent for another,
i.e. it holds link to a child, and another is a child for the first
one, i.e. holds link to a parent. When I try to print it, I get
StackOverflowError since printe