Hello everyone,

I want to use "proc" in a program. Although the original code is good for me, I modify it by "proc" to be convenient. Thank you very much!

With regards

clearall;
restart;
Digits := 15;
## Initial polygon
x[1] := [-1, 1/2, 1, 0, -sqrt(2)/2, -1, 1/2, 1, 0, -sqrt(2)/2, -1, 1/2, 1, 0, -sqrt(2)/2];
y[1] := [0, sqrt(3)/2, 0, -1, -sqrt(2)/2, 0, sqrt(3)/2, 0, -1, -sqrt(2)/2, 0, sqrt(3)/2, 0, -1, -sqrt(2)/2];
s2 := [-1, 1/2, 1, 0, -sqrt(2)/2, -1];
t2 := [0, sqrt(3)/2, 0, -1, -sqrt(2)/2, 0];
assign(a[-6] = 13/1296, a[-5] = -11/648, a[-4] = -1/16, a[-3] = -107/1296, a[-2] = 179/1296, a[-1] = 9/16, a[0] = 137/144, a[1] = 137/144, a[2] = 9/16, a[3] = 179/1296, a[4] = -107/1296, a[5] = -1/16, a[6] = -11/648, a[7] = 13/1296);
L := 3;
N := numelems(x[1]);
## Perform k-1 iterative steps
# L--the number of iterations; nk--the number of refined points after k steps;
for k to L do
nk := 3^(k - 1)*(N - 6) + 6;
for i from 3 to nk - 2 do
x[k + 1][3*i - 8] := a[-6]*x[k][i + 2] + a[-3]*x[k][i + 1] + a[0]*x[k][i] + a[3]*x[k][i - 1] + a[6]*x[k][i - 2];
y[k + 1][3*i - 8] := a[-6]*y[k][i + 2] + a[-3]*y[k][i + 1] + a[0]*y[k][i] + a[3]*y[k][i - 1] + a[6]*y[k][i - 2];
x[k + 1][3*i - 7] := a[-5]*x[k][i + 2] + a[-2]*x[k][i + 1] + a[1]*x[k][i] + a[4]*x[k][i - 1] + a[7]*x[k][i - 2];
y[k + 1][3*i - 7] := a[-5]*y[k][i + 2] + a[-2]*y[k][i + 1] + a[1]*y[k][i] + a[4]*y[k][i - 1] + a[7]*y[k][i - 2];
x[k + 1][3*i - 6] := a[-4]*x[k][i + 2] + a[-1]*x[k][i + 1] + a[2]*x[k][i] + a[5]*x[k][i - 1];
y[k + 1][3*i - 6] := a[-4]*y[k][i + 2] + a[-1]*y[k][i + 1] + a[2]*y[k][i] + a[5]*y[k][i - 1];
end do;
end do;
## Plot the result
s1 := evalf(simplify(convert(x[L+1], list))):t1 := evalf(simplify(convert(y[L+1], list))):
f1 := <<s1> | <t1>>: f2 := <<s2> | <t2>>:
plot([f1, f2], linestyle = [1, 3], color = [black, red]);
T5Scheme:=proc(x[1],y[1],L)
local i,k,nk,result,N,a[-1],a[7],a[6],a[5],a[4],a[3],a[2],a[1],a[0],a[-2],a[-3],a[-4],a[-5]; N:=numelems(x[1]):
for k from 1 to L do
nk := 3^(k - 1)*(N - 6) + 6;
for i from 3 to nk - 2 do
x[k + 1][3*i - 8] := a[-6]*x[k][i + 2] + a[-3]*x[k][i + 1] + a[0]*x[k][i] + a[3]*x[k][i - 1] + a[6]*x[k][i - 2]; y[k + 1][3*i - 8] := a[-6]*y[k][i + 2] + a[-3]*y[k][i + 1] + a[0]*y[k][i] + a[3]*y[k][i - 1] + a[6]*y[k][i - 2]; x[k + 1][3*i - 7] := a[-5]*x[k][i + 2] + a[-2]*x[k][i + 1] + a[1]*x[k][i] + a[4]*x[k][i - 1] + a[7]*x[k][i - 2]; y[k + 1][3*i - 7] := a[-5]*y[k][i + 2] + a[-2]*y[k][i + 1] + a[1]*y[k][i] + a[4]*y[k][i - 1] + a[7]*y[k][i - 2]; x[k + 1][3*i - 6] := a[-4]*x[k][i + 2] + a[-1]*x[k][i + 1] + a[2]*x[k][i] + a[5]*x[k][i - 1];
y[k + 1][3*i - 6] := a[-4]*y[k][i + 2] + a[-1]*y[k][i + 1] + a[2]*y[k][i] + a[5]*y[k][i - 1]; result[1]:=x[L+1]: result[2]:=y[L+1]
end do;
end do;
return result
end proc: