Given a tree, i'm trying to put on a list the values of leaf nodes only.


 



declare

proc {Main T}

 if T\=nil then

 if T.left\=nil then {Main T.left} end

 if T.right\=nil then {Main T.right} end

 if T.left==nil andthen T.right==nil then {Browse T.value} end

 end

end

declare

Root=tree(value:a left:X1 right:X2)

X1=tree(value:b left:nil right:nil)

X2=tree(value:c left:X3 right:X4)

X3=tree(value:d left:nil right:nil)

X4=tree(value:e left:nil right:nil)

{Main Root}



 



With the code above, i know, i simply got b d and e, but i would like to
have [b d e], so i think that i should edit {Browse T.value}. My problem is
how to put the values on a list. Should i use an accumulator? Any idea?


 
 --
 Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP
autenticato? GRATIS solo con Email.it: http://www.email.it/f
 
 Sponsor:
 Alba Adriatica – Giugno e Settembre Offerta bimbi gratis all'hotel Doge
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=10401&d=20100505

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to