Thank's for the quick answer. The "with" statement is a weird one I
shall look into that more closely. But actually the clone itself is
good enough for me.
Problem :
nodes = {}
nodes[0] = LabelledOrderedTree([], 0)
nodes[1] = LabelledOrderedTree([], 1)
nodes[2] = LabelledOrderedTree([], 2)
nodes[0].append(nodes[1])
nodes[1].append(nodes[2])
--> not working
Solution :
nodes = {}
nodes = {}
nodes[0] = LabelledOrderedTree([], 0).clone()
nodes[1] = LabelledOrderedTree([], 1).clone()
nodes[2] = LabelledOrderedTree([], 2).clone()
nodes[0].append(nodes[1])
nodes[1].append(nodes[2])
nodes[0].set_immutable()
nodes[0]
0[1[2[]]]
Working ! So yes, mutable trees exist, they are just a bit difficult to find.
Thank you a lot
Viviane
2012/9/4 Frédéric Chapoton <[email protected]>:
> Il faut utiliser "with" comme ca :
>
> with T.clone() as TT:
> TT[chemin[:-1]]=trees([],None)
>
> Tant qu'on est dans le "with" l'arbre est mutable
>
> Frederic
>
>
> Le lundi 3 septembre 2012 18:57:51 UTC+2, Viviane Pons a écrit :
>>
>> Hi everyone,
>>
>> I'm trying to work with trees but I find them quite difficult to use.
>> I have a simple question : how can I crate a temporary mutable
>> labelled rooted tree and set it to be immutable after the construction
>> is finished ?
>>
>> I have found no way of doing this and this would be necessary for what
>> I'm doing now. If someone know how it works, it would be great.
>>
>> Thank's
>>
>> Viviane
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-combinat-devel" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sage-combinat-devel/-/cRljg5RpUK0J.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sage-combinat-devel?hl=en.
--
You received this message because you are subscribed to the Google Groups
"sage-combinat-devel" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-combinat-devel?hl=en.