Re: Override print-method of struct

2010-10-14 Thread andrei
> 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

Re: Override print-method of struct

2010-10-14 Thread sune.simonsen
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

Re: Override print-method of struct

2010-10-14 Thread andrei
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

Re: Override print-method of struct

2010-10-13 Thread meb
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

Re: Override print-method of struct

2010-10-13 Thread andrei
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

Re: Override print-method of struct

2010-10-13 Thread Laurent PETIT
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

Override print-method of struct

2010-10-13 Thread andrei
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