Hi, I had merrily asumed I could implement nth Fibonacci number with:
takeOne(drop(recurrence!((a, n) => a[n-1] + a[n-2])(zero, one), n)).front where zero and one are of type BigInt, and n is of type size_t. However both dmd and ldc2 complain saying: /usr/include/dmd/phobos/std/range/package.d(5770): Error: template std.bigint.BigInt.opAssign cannot deduce function from argument types !()(immutable(BigInt)) immutable, candidates are: /usr/include/dmd/phobos/std/bigint.d(178): std.bigint.BigInt.opAssign(T)(T x) if (isIntegral!T) /usr/include/dmd/phobos/std/bigint.d(194): std.bigint.BigInt.opAssign(T : BigInt)(T x) /usr/include/dmd/phobos/std/range/package.d(5770): Error: template std.bigint.BigInt.opAssign cannot deduce function from argument types !()(immutable(BigInt)) immutable, candidates are: /usr/include/dmd/phobos/std/bigint.d(178): std.bigint.BigInt.opAssign(T)(T x) if (isIntegral!T) /usr/include/dmd/phobos/std/bigint.d(194): std.bigint.BigInt.opAssign(T : BigInt)(T x) fibonacci.d(25): Error: template instance `fibonacci.declarative.recurrence!((a, n) => a[n - 1] + a[n - 2], immutable(BigInt), immutable(BigInt))` error instantiating /usr/include/dmd/phobos/std/range/package.d(5720): Error: template std.bigint.BigInt.opAssign cannot deduce function from argument types !()(immutable(BigInt)) immutable, candidates are: /usr/include/dmd/phobos/std/bigint.d(178): std.bigint.BigInt.opAssign(T)(T x) if (isIntegral!T) /usr/include/dmd/phobos/std/bigint.d(194): std.bigint.BigInt.opAssign(T : BigInt)(T x) /usr/include/dmd/phobos/std/range/package.d(3177): Error: template instance `std.range.primitives.isInputRange!(Recurrence!(__lambda2, immutable(BigInt), 2LU))` error instantiating fibonacci.d(25): Error: template std.range.drop cannot deduce function from argument types !()(Recurrence!(__lambda2, immutable(BigInt), 2LU), immutable(ulong)), candidates are: /usr/include/dmd/phobos/std/range/package.d(3176): std.range.drop(R)(R range, size_t n) if (isInputRange!R) I am now at the WTF stage – how can I show this example on Thursday in my DevoxxUK presentation? I am close to giving up and imbibing of too much Pernod. -- Russel. =========================================== Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
signature.asc
Description: This is a digitally signed message part