1
function lst=mmodlst(lst)
2
// mmodlst is used to reduce mutiple concatenations, obtained by the
3
// interpretor, such as
6
// to a single one whenever possible
16
if type(lst(ilst))==15 then
17
lst(ilst)=mmodlst(lst(ilst))
20
if type(op)<>10 then op='????',end //bug dans macr2lst
23
if op(2)=='23' then // row concatenation
24
i2=pos(top);i1=pos(top-1)
27
// [a1 a2] contenation
28
if a1(1:2)==['5','23'] then
29
// [a1,a2] is [[a,b,...],a2] replaced by [a,b,...,a2 ]
30
lst(i1)=void;to_kill=[to_kill,i1] //ignore concat which forms a1
31
lst(ilst)(3)=addf(a1(3),'1'); //change rhs of current concat
38
elseif op(2)=='27' then // column concatenation
39
i2=pos(top);i1=pos(top-1)
41
if size(a1,2)<4 then a1(4)=' ',end
44
if size(a2,2)<4 then a2(4)=' ',end
46
// [a1;a2] contenation
47
if a1(1:2)==['5','27'] then
48
// [a1;a2] is [[a;b;...];a2] replaced by [a;b;...;a2 ]
49
lst(i1)=void;to_kill=[to_kill,i1]//ignore concat which forms a1
50
lst(ilst)(3)=addf(a1(3),'1');//change rhs of current concat
53
elseif and(a1(1:2)==['5','23']&a2(1:2)==['5','23'])&a1(3)==a2(3) then
54
// [a1;a2] is [[a,b,...];[x,y,..] replaced by [a,b,...;x,y,..]
55
lst(i1)=void;to_kill=[to_kill,i1]//ignore concat which forms a1
56
lst(i2)=void;to_kill=[to_kill,i2]//ignore concat which forms a2
57
lst(ilst)=['5','33','2',a1(3)];// change op
60
elseif and(a1(1:2)==['5','33']&a2(1:2)==['5','23'])&a1(4)==a2(3) then
61
// [a1;a2] is [[[a,b,...;x,y,..];a2] replaced by [a,b,...;x,y,..;a2]
63
lst(i1)=void;to_kill=[to_kill,i1]//ignore concat which forms a1
64
lst(i2)=void;to_kill=[to_kill,i2]//ignore concat which forms a2
66
lst(ilst)(3)=addf(a1(3),'1');//change rhs of current concat
75
rhs=abs(evstr(op(3)));lhs=evstr(op(4))
76
pos((top-rhs+1):(top-rhs+lhs))=ones(lhs,1)*ilst
82
rhs=abs(evstr(op(3)));lhs=evstr(op(4))
83
pos((top-rhs+1):(top-rhs+lhs))=ones(lhs,1)*ilst
86
elseif opn=='2'|opn=='3'|opn=='4'|opn=='6'|opn=='23' then
93
// purge list of suppressed concatenations
95
for k=1:prod(size(to_kill))
96
lst(to_kill(k))=null();