Tom Womack on Wed, 17 May 2000 12:17:44 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Straightforward question about idioms

I can't believe that this is the most straightforward way of listing the
quadratic fields Q[\sqrt d] with small class number, d<10^4, by class
number. Can anyone suggest a more idiomatic gp method for this, particularly
for the three vector operations that I've had to write out as for loops? Are
there, for example, 'select from vector by predicate' and 'apply function to
all elements of a vector' commands?

bnd = 10000;
L = vector(bnd);
j = 1;
for (i=1,bnd,if(issquarefree(i),L[j]=i:j=j+1));
M = vector(j-1);
for (i=1,j-1,M[i]=if((L[i]%4==3),-L[i],-4*L[i]));
M = qfbclassno(M);
N = vector(j-1);
for (i=1,j-1,N[i]=[L[i],M[i]])
S = vector(10,X,[])
for (i=1,j-1,if((N[i][2]<11),S[N[i][2]]=concat(S[N[i][2]],N[i][1])))