On Mon, Apr 23, 2018 at 11:28 AM, 劉權陞 <01patrick...@gmail.com> wrote:
> I still have no idea about how to write the code. Can you make a
> demonstration?
Something like this:
def set(tree, path, key, value):
for p in path:
tree = tree[p]
tree[key] = value
--
Zach
__
I still have no idea about how to write the code. Can you make a
demonstration?
2018-04-23 0:42 GMT+08:00 Zachary Ware :
> Basically what you want to do here is give Tree a local name (d), loop
> through T reassigning d to d[k_from_T], and then d[k] = v after the loop. T
> can be arbitraily long
Basically what you want to do here is give Tree a local name (d), loop
through T reassigning d to d[k_from_T], and then d[k] = v after the loop. T
can be arbitraily long, and Tree can actually be and contain any indexable
type.
If this pointer isn't enough to send you in the right direction, I'll
To deposit a nodes in the tree (adding a new node), for example: put 3: {}
in the Tree branch at branch tuple (2, 4, 1, 5) .
If don't use :
def f(T,k,v):
m=len(T)
if m==0:
Tree[k]=v
elif m==1:
Tree[T[0]][k]=v
elif m==2:
Tree[T[0]][T[1]][k]=v
elif m==3: