iota and BigInt
Russel Winder
russel at winder.org.uk
Tue May 28 00:55:10 PDT 2013
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 at ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: russel at winder.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130528/bf631b89/attachment-0001.pgp>
More information about the Digitalmars-d
mailing list