Question: programming help needed

I need help on turning this code into a procedure and what changes do i have to make  so it works like the gauss-seidel algorithm. I have tried many times on my own but can't seem to get my head around it. Any help would be appriciated greatly.
 

 

restart:
n:=3:
    s:=Matrix([[2,1/3,-2/3],[-5/4,-5,5/4],[21/5,-14/5,7]]):
       b:=[2/3,-15/2,98/5]:
          X:=[0,0,0]:
             maxitr:=11:

 for k from 1 to maxitr do
    print(`Iteration number`);
      k;
       print(`Previous iteration value`);
         X_0:=X;


          for i from 1 to n do

            summ:=0.0:

          for j from 1 to n do

            if (i<>j) then
            summ:=summ + (s[i,j]*X[j]);

         end if;
       end do:

     X[i]:=(b[i]-summ)/s(i,i);
    end do;

   print(`new iterative value`);
       X;
end do;


oh yh if there is any mistake in my code please let me know.
 

Please Wait...