John Cremona on Wed, 16 Mar 2016 14:08:14 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Proposal to extend primes() |
Wow, gp syntax is getting quite sophisticated these days! John On 16 March 2016 at 12:16, Karim Belabas <Karim.Belabas@math.u-bordeaux.fr> wrote: > * John Cremona [2016-03-16 12:48]: >> DIfferent people will want different abbreviations for their common >> use case. I can imagine wanting (for example) primes(1,4) to mean >> primes congruent to 1 mod 4 (and then another parameter needed for a >> bound). I can also imagine a *very* common use for primes(pmax, N) >> returning the primes up to pmax which do not divide N. > > An unrelated note: Comprehension already allows to express this in > a natural way: > > [ p | p <- primes([2,1000]), N % p != 0 ] > > N.B. And so would > > [ n | n <- [2..1000], isprime(n) && N % n ] > > without bothering about primes() and how to pass its arguments, but the > call to isprime() in this latter construction is a major loss of > efficiency. (While I see no way to produce primes coprime to N in a > significantly faster way than the first algorithm.) > > Cheers, > > K.B. > -- > Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 > Universite de Bordeaux Fax: (+33) (0)5 40 00 69 50 > 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ > F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] > `