Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -50,8 +50,6 @@ OP TOHTML = ( REF NODE tree )STRING:
|
|||
THEN
|
||||
# the node has branches #
|
||||
REF NODE child := child OF tree;
|
||||
INT child number := 1;
|
||||
INT mid child = ( child count + 1 ) OVER 2;
|
||||
child := child OF tree;
|
||||
result +:= tr + nl;
|
||||
WHILE child ISNT nil node
|
||||
|
|
@ -78,7 +76,7 @@ OP +:= = ( REF NODE n, REF NODE sibling node )REF NODE:
|
|||
DO
|
||||
sibling := sibling OF sibling
|
||||
OD;
|
||||
sibling OF sibling := sibling node
|
||||
sibling OF sibling := sibling node # will get a potential scope violation warning #
|
||||
END # +:= # ;
|
||||
# appends a new sibling node to the node n, returns the sibling #
|
||||
OP +:= = ( REF NODE n, STRING sibling value )REF NODE: n +:= new node( sibling value );
|
||||
|
|
|
|||
36
Task/Visualize-a-tree/XPL0/visualize-a-tree.xpl0
Normal file
36
Task/Visualize-a-tree/XPL0/visualize-a-tree.xpl0
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
int SDown, SLast, SNone;
|
||||
|
||||
proc Tree(Root, Head);
|
||||
int Root, Head;
|
||||
int Col(2), Tail, R;
|
||||
def \Stem\ Str, Next;
|
||||
[Col(Str):= 0; Col(Next):= 0;
|
||||
Tail:= Head;
|
||||
loop [if Tail = 0 then quit;
|
||||
Text(0, Tail(Str));
|
||||
if Tail(Next) = 0 then quit;
|
||||
Tail:= Tail(Next);
|
||||
];
|
||||
Text(0, "--"); IntOut(0, Root); CrLf(0);
|
||||
|
||||
if Root <= 1 then return;
|
||||
|
||||
if Tail # 0 then
|
||||
if Tail(Str) = SLast then
|
||||
Tail(Str):= SNone;
|
||||
|
||||
if Tail = 0 then [Tail:= Col; Head:= Col]
|
||||
else Tail(Next):= Col;
|
||||
|
||||
while Root do \\ make a tree by doing something random
|
||||
[R:= 1 + Ran(Root);
|
||||
Root:= Root - R;
|
||||
Col(Str):= if Root # 0 then SDown else SLast;
|
||||
Tree(R, Head);
|
||||
];
|
||||
Tail(Next):= 0;
|
||||
];
|
||||
|
||||
[SDown:= " |"; SLast:= " `"; SNone:= " ";
|
||||
Tree(8, 0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue