@@ -1184,8 +1184,8 @@ int is_nth_power(const bigint& x, int n)
11841184 if ((x<0 ) && (n%2 ==0 ))
11851185 return 0 ;
11861186 vector<bigint> plist = pdivs (x);
1187- return std::all_of (plist. begin (), plist. end (),
1188- [n,x]( const bigint& p){ return val (p,x)%n== 0 ;} );
1187+ auto local_condition = [n,x]( const bigint& p){ return val (p,x)%n== 0 ;};
1188+ return std::all_of (plist. begin (), plist. end (), local_condition );
11891189}
11901190
11911191bigint prime_to_S_part (const bigint& x, const vector<bigint>& S)
@@ -1279,36 +1279,37 @@ vector<bigint> powers(const bigint& n, int maxexp)
12791279 bigint np (1 );
12801280 npowers[0 ] = np;
12811281 int e = 0 ;
1282- std::generate (npowers. begin ()+ 1 , npowers. end (),
1283- [n, &np, &e](){np*=n; e++; return np;} );
1282+ auto next_power = [n, &np, &e](){np*=n; e++; return np;};
1283+ std::generate (npowers. begin ()+ 1 , npowers. end (), next_power );
12841284 return npowers;
12851285}
12861286
12871287// [n^e for e in exponents]
12881288vector<bigint> powers (const bigint& n, const vector<int >& exponents)
12891289{
12901290 vector<bigint> npowers (exponents.size ());
1291- auto e = exponents.begin ();
1292- std::generate (npowers.begin (), npowers.end (),
1293- [n, &e](){return pow (n, *e++);;});
1291+ auto npower = [n](int e){return pow (n,e);};
1292+ std::transform (exponents.cbegin (), exponents.cend (), npowers.begin (), npower);
12941293 return npowers;
12951294}
12961295
12971296// Compute N from its factorization (lists of primes and exponents) --
12981297// (name taken from gp)
12991298bigint factorback (const vector<bigint>&PP, const vector<int >& EE)
13001299{
1300+ static const bigint one (1 );
1301+ auto power = [](const bigint& p, int e){return pow (p,e);};
13011302 return std::transform_reduce (PP.cbegin (), PP.cend (), EE.cbegin (),
1302- bigint (1 ), // initial value
1303- std::multiplies<>(), // how to combine terms,
1304- [](const bigint& p, int e){return pow (p,e);} // how to form terms
1305- );
1303+ one, // initial value
1304+ std::multiplies<>(), // how to combine terms,
1305+ power); // how to form terms
13061306}
13071307
13081308// Maximum conductor for a given list of primes
13091309bigint MaxN (const vector<bigint>&PP)
13101310{
1311- bigint N (1 );
1311+ static const bigint one (1 );
1312+ bigint N (one);
13121313 std::for_each (PP.cbegin (), PP.cend (),
13131314 [&N](const bigint& p){N *= pow (p, (p==2 ?8 :p==3 ?5 :2 ));});
13141315 return N;
@@ -1325,8 +1326,8 @@ bigint radical(const bigint& N)
13251326vector<bigint> multiply_list (const bigint& a, const vector<bigint>& L)
13261327{
13271328 vector<bigint> aL (L.size ());
1328- std::transform (L. begin (), L. end (), aL. begin (),
1329- [a]( const bigint& x){ return a*x;} );
1329+ auto times_a = [a]( const bigint& x){ return a*x;};
1330+ std::transform (L. begin (), L. end (), aL. begin (), times_a );
13301331 return aL;
13311332}
13321333
@@ -1354,7 +1355,8 @@ vector<bigint> multiply_list_by_powers(const bigint& p, const vector<int>& expon
13541355vector<bigint> bigintify (const vector<long >& L)
13551356{
13561357 vector<bigint> LL (L.size ());
1357- std::transform (L.cbegin (), L.cend (), LL.begin (), [](long x){return bigint (x);});
1358+ auto long2big = [](long x){return bigint (x);};
1359+ std::transform (L.cbegin (), L.cend (), LL.begin (), long2big);
13581360 return LL;
13591361}
13601362
0 commit comments