| 1 |
.PS |
| 2 |
# Ttree.m4 |
| 3 |
# A binary tree using m4 |
| 4 |
gen_init |
| 5 |
sinclude(tst.dim) |
| 6 |
s_init(Ttree) |
| 7 |
|
| 8 |
# `Node(no in row, head [location], |
| 9 |
# displacement of top of body (.n) wrt head, |
| 10 |
# body Node 1, body Node 2, ...) ' |
| 11 |
define(`Node',` |
| 12 |
Head`$1': `$2' |
| 13 |
ifelse(`$3',,,` Body`$1': [ |
| 14 |
Loopover_(`v',`v; define(`m4ct',m4Lx)',shift(shift(shift($@)))) |
| 15 |
] with .n at Head`$1' + `$3' |
| 16 |
connect(`$1',m4ct)')') |
| 17 |
|
| 18 |
define(`connect',`Bot: move from Head$1.sw-(0,5bp__) to Head$1.se-(0,5bp__) |
| 19 |
for_(1,`$2',1, |
| 20 |
`Top: move from Body$1.Head`'m4x.nw+(0,2bp__) \ |
| 21 |
to Body$1.Head`'m4x.ne+(0,2bp__) |
| 22 |
Mov: move from Head$1 to Body$1.Head`'m4x |
| 23 |
if Bot.len*Top.len*Mov.len > 0 then { |
| 24 |
line from Intersect_(Mov,Top) to Intersect_(Mov,Bot)}')') |
| 25 |
|
| 26 |
vsep = 0.75 |
| 27 |
define(`txw',`wid `$1'mm__')dnl scaled by 14/12 for 14 pt type |
| 28 |
|
| 29 |
Node(1,"svg_it(h(h(h(x`'svg_sub(1),x`'svg_sub(2))," \ |
| 30 |
+ "h(x`'svg_sub(3),x`'svg_sub(4))),h(h(x`'svg_sub(5),x`'svg_sub(6))," \ |
| 31 |
+ "h(x`'svg_sub(7),x`'svg_sub(8)))))" txw(70) , |
| 32 |
(0,-vsep), |
| 33 |
Node(1,"svg_it(h(h(x`'svg_sub(1),x`'svg_sub(2)),h(x`'svg_sub(3)," \ |
| 34 |
+ "x`'svg_sub(4))))" txw(32) , |
| 35 |
(0,-vsep), |
| 36 |
Node(1,"svg_it(h(x`'svg_sub(1),x`'svg_sub(2)))" txw(14) , |
| 37 |
(0,-vsep), |
| 38 |
Node(1,"svg_it(x`'svg_sub(1):=((A,pk`'svg_sub(A)),h`'svg_sub(1)))" \ |
| 39 |
txw(29) ), |
| 40 |
Node(2,"svg_it(x`'svg_sub(2):=((B,pk`'svg_sub(B)),h`'svg_sub(2)))" \ |
| 41 |
txw(29) with .n at last "".ne+(0.2,-vsep*2/3))), |
| 42 |
Node(2,"svg_it(h(x`'svg_sub(3),x`'svg_sub(4)))" txw(14) \ |
| 43 |
with .nw at Head1.ne+(Body1.wid/2+0.1,0), |
| 44 |
(0,-vsep), |
| 45 |
Node(1,"svg_it(x`'svg_sub(3):=" \ |
| 46 |
+ "((A,pk`'svg_prime`'svg_sub(A,,,-0.5ex)),h`'svg_sub(3)))" \ |
| 47 |
txw(29)), |
| 48 |
Node(2,"svg_it(x`'svg_sub(4):=((D,pk`'svg_sub(D)),h`'svg_sub(4)))" \ |
| 49 |
txw(29) with .n at last "".ne+(0.2,-vsep*2/3)))), |
| 50 |
Node(2,"svg_it(h(h(x`'svg_sub(5),x`'svg_sub(6)),h(x`'svg_sub(7)," \ |
| 51 |
+ "x`'svg_sub(8))))" txw(29) with .nw at Head1.ne+(Body1.wid/2,0), |
| 52 |
(0,-vsep), |
| 53 |
Node(1, "svg_it(h(x`'svg_sub(5),x`'svg_sub(6)))" txw(14) , |
| 54 |
(0,-vsep*5/4), |
| 55 |
Node(1,"svg_it(x`'svg_sub(5):=((E,pk`'svg_sub(E)),h`'svg_sub(5)))" \ |
| 56 |
txw(29) ), |
| 57 |
Node(2,"svg_it(x`'svg_sub(6):=((H,pk`'svg_sub(H)),h`'svg_sub(6)))" \ |
| 58 |
txw(29) with .n at last "".ne+(0.2,-vsep*2/3))), |
| 59 |
Node(2,"svg_it(h(x`'svg_sub(7),x`'svg_sub(8)))" txw(14) \ |
| 60 |
with .nw at Head1.ne+(Body1.wid/2+0.1,0), |
| 61 |
(0,-vsep*5/4), |
| 62 |
Node(1,"svg_it(x`'svg_sub(7):=" \ |
| 63 |
+ "((D,pk`'svg_prime`'svg_sub(D,,,-0.5ex)),h`'svg_sub(7)))" \ |
| 64 |
txw(29) ), |
| 65 |
Node(2,"svg_it(x`'svg_sub(8):=((K,pk`'svg_sub(K)),h`'svg_sub(8)))" \ |
| 66 |
txw(29) with .n at last "".ne+(0.2,-vsep*2/3))), |
| 67 |
Node(3,"svg_it(h(x`'svg_sub(9)))" txw(8) \ |
| 68 |
at 0.5 between Head1 and Head2))) |
| 69 |
|
| 70 |
.PE |