Function: _forprimestep_init
Class: gp2c_internal
Help: Initialize forprime_t.
Description:
 (forprime,int,?int,int):void             forprimestep_init(&$1,$2,$3,$4);

Function: forprimestep
Section: programming/control
C-Name: forprimestep
Prototype: vV=GDGGI
Help: forprimestep(p=a,b,q,seq): the sequence is evaluated, p running over the
 primes less than b in the arithmetic progression a + k*q, k >= 0.
 The parameter q can be a positive integer or an intmod (start at the first
 prime above a in the progression).
Iterator:
 (*notype,small,small,gen)  (forprime, _forprimestep_init, _u_forprime_next)
 (*notype,gen,gen,gen)      (forprime, _forprimestep_init, _forprime_next_)
 (*small,gen,?gen,gen)      (forprime, _forprimestep_init, _u_forprime_next)
 (*int,gen,?gen,gen)        (forprime, _forprimestep_init, _forprime_next_)
 (gen,gen,?gen,gen)         (forprime, _forprimestep_init, _forprime_next_)
Doc: evaluates \var{seq}, where the formal variable $p$ ranges over the prime
 numbers in an arithmetic progression in $[a,b]$: $q$ is either an integer
 ($p \equiv a \pmod{q}$) or an intmod \kbd{Mod(c,N)} and we restrict
 to that congruence class. Nothing is done if $a>b$.
 \bprog
 ? forprimestep(p = 4, 30, 5, print(p))
 19
 29
 ? forprimestep(p = 4, 30, Mod(1,5), print(p))
 11
 @eprog\noindent Setting $b$ to \kbd{+oo} means we will run through all primes
 $\geq a$, starting an infinite loop; it is expected that the caller will break
 out of the loop itself at some point, using \kbd{break} or \kbd{return}.

 Note that the value of $p$ cannot be modified within \var{seq}:
 \bprog
 ? forprimestep(p = 2, 10, 3, p = [])
  ***   at top-level: forprimestep(p=2,10,3,p=[])
  ***                                         ^---
  ***   prime index read-only: was changed to [].
 @eprog
