Re: Segfault games with factorials

2014-07-24 Thread safety0ff via Digitalmars-d-learn
On Thursday, 24 July 2014 at 14:59:16 UTC, Darren wrote: It does seem that's the case. Which is odd, as I thought that DMD and LDC did TCO. Not in this case obviously. DMD doesn't do it with the :? operator: https://issues.dlang.org/show_bug.cgi?id=3713

Re: Segfault games with factorials

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 14:59:16 UTC, Darren wrote: On Thursday, 24 July 2014 at 14:39:12 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote: I have the following code in fac.d (modified from the factorial examples

Re: Segfault games with factorials

2014-07-24 Thread Darren via Digitalmars-d-learn
On Thursday, 24 July 2014 at 14:39:12 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote: I have the following code in fac.d (modified from the factorial examples on RosettaCode): #!/usr/bin/rdmd import std.bigint; pure

Re: Segfault games with factorials

2014-07-24 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote: > I have the following code in fac.d (modified from the factorial > examples on RosettaCode): > > #!/usr/bin/rdmd > import std.bigint; > > pure BigInt factorial(BigInt n) { > static pure BigInt inner(BigInt n, Big

Segfault games with factorials

2014-07-24 Thread Darren via Digitalmars-d-learn
I have the following code in fac.d (modified from the factorial examples on RosettaCode): #!/usr/bin/rdmd import std.bigint; pure BigInt factorial(BigInt n) { static pure BigInt inner(BigInt n, BigInt acc) { return n == 0 ? acc : inner(n - 1, acc * n); } return inner(n, BigI