IMPORTS
Basics, Convert, IFUPW, PW, Rope
FlatTree:
PUBLIC
PROC [root:
PW.
ROPE, levels:
CARDINAL]
RETURNS[new:
PW.ObjName]= {
IF root is "Foo" then this procedure assumes the existance of:
Foo, FooExtend, FooConn, FooDrRt, FooDrLt, FooBlank and FooPass
as well as FooEnd
list: LIST OF PW.ObjName;
limit: CARDINAL ← PW.TwoToThe[levels]-2;
FOR index:
CARDINAL
IN [0..limit]
DO
list ← CONS[FlatTreeCell[root, levels, index], list] ENDLOOP;
list ← CONS[Rope.Cat[root, "End"], list];
new ← PW.AbutListX[list] };
FlatTreeCell:
PROC [root:
PW.
ROPE, levels, index:
CARDINAL]
RETURNS[new:
PW.ObjName]= {
IF root is "Foo" then this procedure assumes the existance of:
Foo, FooExtend, FooConn, FooDrRt, FooDrLt, FooBlank and FooPass
level, test: CARDINAL ← 0;
list: LIST OF PW.ObjName;
ConsName: PROC[type: PW.ROPE] = {list ← CONS[Rope.Cat[root, type], list]};
ConsName[""];
FOR test←index, test/2
WHILE (test
MOD 2 )=1
DO
ConsName["Extend"]; level ← level +1 ENDLOOP;
ConsName["Conn"]; level ← level +1; test ← Basics.BITXOR[test/2, test];
ConsName[IF (test MOD 2 )=1 THEN "DrRt" ELSE "DrLt"];
THROUGH (level..levels]
DO
IF ((test←test/2)
MOD 2)=0
THEN ConsName["Blank"]
ELSE ConsName["Pass"]
ENDLOOP;
new ← PW.AbutListY[ReverseList[list]] };
TreeConditionals:
PROC [index:
CARDINAL, root:
PW.
ROPE]
RETURNS[list:
LIST
OF
PW.
ROPE]= {
level, test: CARDINAL ← 0;
ConsName:
PROC[type:
PW.
ROPE] =
{list ← CONS[Rope.Cat[root, "L", Convert.RopeFromCard[level], type], list]};
FOR test←index, test/2
WHILE (test
MOD 2 )=1
DO
ConsName["Extend"]; level ← level +1 ENDLOOP;
ConsName["Conn"]; level ← level +1; test ← Basics.BITXOR[test/2, test];
ConsName[IF (test MOD 2 )=1 THEN "PassRt" ELSE "PassLt"];
FOR test←test/2, test/2
WHILE test#0
DO
level ← level +1;
IF (test MOD 2 )=0 THEN LOOP;
ConsName["PassLt"];
ConsName["PassRt"];
ENDLOOP };