iota and BigInt

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 22 10:21:41 PST 2015


On Thu, Jan 22, 2015 at 05:12:17PM +0000, Russel Winder via Digitalmars-d-learn wrote:
> Using reduce for factorial, seems to require iota, not a bad things
> per se, with ulongs:
> 
> 	reduce!"a*b"(1, iota(1, n + 1))
> 
> works fine. Now switch to BigInt:
> 
> 	reduce!"a*b"(one, iota(one, n + one))
> 
> fails to compile, one and n + one are of different types. Problem is
> that one is immutable but n + one is not. I can't remember how to
> create an immutable value as an expression so:
> 
> 	immutable BigInt v = n + one;
> 	reduce!"a*b"(one, iota(one, v))
> 
> now I get an error telling me that I can't use iota because BigInt is
> not a float or an integer. Is this a known bug? Yes it is:
> https://issues.dlang.org/show_bug.cgi?id=6447
> 
> Does anyone know how to fix this 3.5 year old bug that is a blocker
> for doing anything with factorial and Fibonacci Series.?
[...]

https://github.com/D-Programming-Language/phobos/pull/2895

This is just the tip of the iceberg. The full enhancement is described
in:

	https://issues.dlang.org/show_bug.cgi?id=10762


T

-- 
Give a man a fish, and he eats once. Teach a man to fish, and he will sit forever.


More information about the Digitalmars-d-learn mailing list