I recently wrote a program for quickly finding quadratic residues in Maple;
quadres := proc (n::posint)
global k, L, Sorting;
Sorting := proc (X)
global Y, i, j, z;
Y := X;
for i to nops(Y)-1 do
for j to nops(Y)-i do
if Y[j+1] <= Y[j] then z := Y[j]; Y[j] := Y[j+1]; Y[j+1] := z end
if end do end do;
eval(Y) end proc;
for k from 0 to n-1 do
mod(k^2, n) end do;L := [seq(
mod(k^2, n), k = 1 .. (1/2)*n-1/2)];Sorting(L);
print(n = Sorting(L))
end proc;
My question is this. I want to convert this to a point plot program so that I can plot larger numbers of data to look for patterns. The axes will be moduli (x-axis) vs. residues (y-axis). Thus, for moduli 2,3,4,and 5, the ordered pairs will be $$\{(3,1),(4,1),(5,1),(5,4),(6,1),(6,4), (7,1),(7,2),(7,4)\}$$. Any thoughts on how to write the program would be helpful. I'm a novice with Maple, but catch on quick.

sortcommand, but very likely don't need your own sorting implementation (efficient or not), and certaily not one which gets its body redefined each timequadresis called. – acer Feb 08 '14 at 00:23mapletag) or www.mapleprimes.com – acer Feb 10 '14 at 00:59