What does PARI mean by "showing all possibilites"?

46 Views Asked by At

I am running this code, unfortunately I have no idea that why it is asking me a yes or no question.

 Normu(D) = my(k = bnfinit(y^2-D, 1), u = bnfunits(k)[1][1]); nfeltnorm(k, u); 
  {
    L = List();
    forprime (q = 5, 100,
      if (q%8==5, 
        N2 = Normu(q);
        forprime(p = q+1, 100,
          if(p%8==5,
            N1 = Normu(2*p);
            N3 = Normu(2*p*q);
            istput(L, [[q,p], [N1, N2, N3]])))));
  }

Unfortunately I can not undrestand what PARI means by 'showing all possibilities'and asks me to type(y or n).

I tried to change commands, and change the default PARI size, but not successful. I know the problem is not in the function defined above. I appreciate your help.

Update: I wrote all the code in one line and it is working but it doesn't consider internal 'if's . It is not clear to me why it should work with this change.

    
 Normu(D) = my(k = bnfinit(y^2-D, 1), u = bnfunits(k)[1][1]); nfeltnorm(k, u); 
  {
    L = List();
    forprime (q = 5, 100, if (q%8==5, N2 = Normu(q);  forprime(p = q+1, 100, if(p%8==5, N1 = Normu(2*p); N3 = Normu(2*p*q); listput(L,[[q,p], [N1, N2, N3]])))));
  }

1

There are 1 best solutions below

0
K.B. On

The message you're seeing Display all ... possibilities? (y or n) is produced by the readline library providing line editing to the gp binary. More precisely, it is the completion mechanism, triggered when pressing the <TAB> key. Presumably you used <TAB> character to indent your code, then copy-pasted it into a gp terminal. The "corrected" version works because you presumably removed all <TAB> characters when writing the program on a single line.

Try typing <TAB> at the gp prompt, you'll see the above message because gp is trying to complete the expression without any context, so there are lots of possibilities (all built-in and user functions, and all variables, and all operators). Since all possibilities can't be written down in a single screen of results, you're being asked if you really want to display all the possibilities; by typing y you'll be shown possible completions one screenful at a time.

Compare with d<TAB> for instance and you'll be shown all completion starting by d (about 24 of them, no question this time since this fits into a single screen.

P.S. The original program has a typo in the final lines: istput instead of listput.