May 28, 2013 iota and BigInt | ||||
---|---|---|---|---|
| ||||
Attachments:
| Arising from a thread on the GoLangNuts email list, I wrote the following: 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), BigInt(i)))); } 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 — as opposed to those pesky limited hardware things ;-) ./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)) || isPointer!(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!(CommonType!(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.range.iota cannot deduce template function from argument types !()(BigInt,BigInt) Failed: 'dmd' '-v' '-o-' './numbers_multiplePasses.d' '-I.' Thanks. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 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 |
Copyright © 1999-2021 by the D Language Foundation