Origins of the D Programming Language

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Dec 4 17:07:46 UTC 2018


On Tue, Dec 04, 2018 at 07:31:28AM +0000, Russel Winder via Digitalmars-d wrote:
> On Mon, 2018-12-03 at 23:42 +0000, Q. Schroll via Digitalmars-d wrote:
> > […]
> > 
> > ulong factorial(ulong n) {
> >    ulong result = 1;
> >    foreach (i; 0 .. n) result *= i; // off by one.
> >    return result;
> > }
> > 
> > Even the best make mistake ;)
> 
> Being serious for a moment: anyone implementing factorial using ulong
> is doing it wrong.  std.bigint.BigInt is the only type that makes
> sense in a D implementation of factorial – also fibonacci.
[...]

And this is where a simple code example explodes into a hairy
over-engineered mess. Totally correct, mind you, but totally missing the
point of being an example of D code. :-P


T

-- 
What's an anagram of "BANACH-TARSKI"?  BANACH-TARSKI BANACH-TARSKI.


More information about the Digitalmars-d mailing list