At the moment I'm trying to find the smallest difference between two things (of form E[i] i goes from 1 to n) and input them in a list. To do this I need to use nested loops but I'm not sure of the best kind/way to do this. I have been experimenting with for and if loops so far
for instance, this is my most recent effort.
for i from 2 to n do;
a := abs(E[i]-E[1]);
for j from 2 to n do;
if i <> j then ;
b := abs(E[i]-E[j]);
end if;
if b < a then a := b end if;
end do;
N := [op(N), a] ;
end do;
(was planning on writing a seperate loop for i=1 case here).
I am really struggling to find a way to make it work though, particularly as I need to do all cases E[i]-E[j] i,j=1...n i<>j. I think my trouble lies in the original defining of a (and what to set it as/how to reset it for the next i case), and when to put the command N := [op(N), a] ; into the loop
Can anyone help me with this problem?