File: modlst.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (86 lines) | stat: -rw-r--r-- 1,968 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function [lst]=modlst(lst)
//
//!
//count=count+1
// Copyright INRIA
nlst=size(lst);top=0
ilst=0
pos=[]
while ilst<nlst
  ilst=ilst+1
  if type(lst(ilst))==15 then
    lst(ilst)=modlst(lst(ilst))
  else
    op=lst(ilst)
    opn=op(1)
    if opn=='5' then
       if op(2)=='23' then
 
         i2=pos(top);i1=pos(top-1)
         a1=lst(i1)
         a2=lst(i2)
         if a1(1:2)==['5','23'] then
             // [ [a,b,...],x ]
             lst(i1)='0';
             op(3)=addf(a1(3),'1');lst(ilst)=op
             top=top-1
             pos(top)=ilst
         else
             top=top-1
             pos(top)=ilst
         end
       elseif op(2)=='27' then
 
         i2=pos(top);i1=pos(top-1)
         a1=lst(i1)
         a2=lst(i2)
         if a1(1:2)==['5','27'] then
             // [ [a;b;...];x ]
             lst(i1)='0';
             op(3)=addf(a1(3),'1');lst(ilst)=op
             top=top-1
             pos(top)=ilst
         elseif a1(1:2)==['5','23']&a2(1:2)==['5','23'] then
             lst(i1)='0'
             lst(i2)='0'
             op=['5','33','2',a1(3)];lst(ilst)=op;
         elseif a1(1:2)==['5','28']&a2(1:2)==['5','23'] then
             lst(i1)='0';
             lst(i2)='0'
             op(3)=addf(a1(3),'1');lst(ilst)=op;
             top=top-1
             pos(top)=ilst
         else
             top=top-1
             pos(top)=ilst
         end
       else
         rhs=abs(evstr(op(3)));lhs=evstr(op(4))
         pos((top-rhs+1):(top-rhs+lhs))=ones(lhs,1)*ilst
         top=top-rhs+lhs
 
       end
    elseif opn=='20' then
       rhs=abs(evstr(op(3)));lhs=evstr(op(4))
       pos((top-rhs+1):(top-rhs+lhs))=ones(lhs,1)*ilst
       top=top-rhs+lhs
    elseif opn=='2'|opn=='3'|opn=='4'|opn=='6'|opn=='23' then
       top=top+1
       pos(top)=ilst
//    else
    end
  end
end
 
lst1=list();k1=0;
for ll=lst;
  if type(ll)==15 then
     k1=k1+1;lst1(k1)=ll
  elseif ll(1)<>'0' then
     k1=k1+1;lst1(k1)=ll,
  end
end
lst=lst1;