www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - iota and BigInt

Arising from a thread on the GoLangNuts email list, I wrote the

        import std.algorithm: reduce;
        import std.bigint;
        import std.range: iota;
        import std.stdio: writeln;
        int main(immutable string[] args) {
          foreach (int i; iota(10, 50, 10)) {
            writeln(reduce!"a * b"(BigInt(1), iota(BigInt(1),
          return 0;
Sadly the compiler refuses to acknowledge that iota works for BigInt. My
first assumption is that my code is wrong. My second assumption is that
std.range doesn't work with real integers =E2=80=94 as opposed to those pes=
limited hardware things ;-)=20

        ./numbers_multiplePasses.d(10): Error: template std.range.iota does=
 not match any function template declaration. Candidates are:
        /usr/include/dmd/phobos/std/range.d(5107):        std.range.iota(B,=
 E, S)(B begin, E end, S step) if ((isIntegral!(CommonType!(B, E)) || isPoi=
nter!(CommonType!(B, E))) && isIntegral!(S))
        /usr/include/dmd/phobos/std/range.d(5192):        std.range.iota(B,=
 E)(B begin, E end) if (isFloatingPoint!(CommonType!(B, E)))
        /usr/include/dmd/phobos/std/range.d(5199):        std.range.iota(B,=
 E)(B begin, E end) if (isIntegral!(CommonType!(B, E)) || isPointer!(Common=
Type!(B, E)))
        /usr/include/dmd/phobos/std/range.d(5260):        std.range.iota(E)=
(E end)
        /usr/include/dmd/phobos/std/range.d(5267):        std.range.iota(B,=
 E, S)(B begin, E end, S step) if (isFloatingPoint!(CommonType!(B, E, S)))
        /usr/include/dmd/phobos/std/range.d(5107): Error: template std.rang=
e.iota cannot deduce template function from argument types !()(BigInt,BigIn=
        Failed: 'dmd' '-v' '-o-' './numbers_multiplePasses.d' '-I.'


Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.n=
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
May 28 2013