Karim Belabas on Wed, 11 Dec 2024 22:28:56 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Is this the way to use auxiliary variables in vector initialized via multiple iterators?
|
- To: hermann@stamm-wilbrandt.de, pari-users@pari.math.u-bordeaux.fr
- Subject: Re: Is this the way to use auxiliary variables in vector initialized via multiple iterators?
- From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
- Date: Wed, 11 Dec 2024 22:28:52 +0100
- Delivery-date: Wed, 11 Dec 2024 22:28:56 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=math.u-bordeaux.fr; s=2022; t=1733952534; bh=2jbbLI5enS3LyZuMWzy/Q+Q2xNXLbsnavMjn3xtX6Qg=; h=Date:From:To:Subject:References:In-Reply-To:From; b=ngau+nU0BMMJ3vOz3WBf+SWf68OlWvALoaSWaMiUO6GThyDqaL9YFY+7+HL0lB03B QSXWldPpl8JtD5fssdZos4Q9BwGEk8zqtlPDK+jQaYWTGMmIcYMslilpS+65pLCPNp M7p4vVynPkjOdosgW0ffgcCEXyIXdxEuty42V9q0Pzjus6riCOPVhlCqh3vLqJaPXW ch2fFRQJ+8BNFnFqkhdrkC9RLVYLRCE76DM+D/GRa5Nqcfy31GNm9eCHlNJkJSCdGb s7JxidJePsoKIHO6tpPZWOk0pGvE5xzYDCLjVv52xpy5vr9l9JVT48NFUEAk/mLZ0A Oqn0c7f5Egp2J5JXODkf742KG4xl7L0eAjubFXzyVufmoH5OUK7jH+FK1C5Dx9wqZ7 bld4MjZPaCUGy75z00+jPnDJW6KGmAGciZA9biI22SzaLiT4jEiTs2DutG3Ngj2MbR PeUB0B/Z19zqQIIPIHLqJxa1TcvwXWq8xElqWy1Hhq95d98RLKiNICc/O3qPkPlTTO NSeL6ZsKyjbXDRvwqZWYFb0bLZG2uFhTn0Aga106ZnxdIDbeBgm7sBzVPa+uo9Em/t FjWXyhGIgVUA5y5EypqK5K0BjPJTb5KZdjKDTiU2HnFLz9H7De5yRsLhqTWC1o7JFT V7NvYNALetQW95nH36Ns6ork=
- In-reply-to: <Z1oC_u7Ag5z21tfH@math.u-bordeaux.fr>
- Mail-followup-to: hermann@stamm-wilbrandt.de, pari-users@pari.math.u-bordeaux.fr
- References: <aedc5877d37d87f01df04b099964c84d@stamm-wilbrandt.de> <Z1oC_u7Ag5z21tfH@math.u-bordeaux.fr>
* Karim Belabas [2024-12-11 22:24]:
> * hermann@stamm-wilbrandt.de [2024-12-11 22:16]:
> > Doc talks about
> > https://pari.math.u-bordeaux.fr/pub/pari/manuals/2.17.0/users.pdf#page=25
> >
> > "To iterate over more than one variable, you may separate clauses with ; as
> > in"
> >
> > I found no mentioning how to introduce auxiliary variables to avoid
> > repetition of terms.
> >
> > I wanted to use auxiliary variable s for sum p^2+4*q^2, and this does the
> > job:
> >
> > ? P=primes([2,100]);vecmin([s|p<-P;q<-P;s<-[p^2+4*q^2],isprime(s)])
> > 41
> > ?
> >
> > Is there another way of assignment to s without having to introduce
> > auxiliary single element set?
>
> P = primes([2,100]); vecmin([s | p<-P;q<-P, isprime(s = p^2+4*q^2)])
Another possibility is the more general 'if (true,)' hack to introduce
an arbitrary sequence of instructions, where a single one is allowed:
vecmin([s | p<-P;q<-P, if (1, s = p^2+4*q^2; isprime(s))])
Cheers,
K.B.
--
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/