RosettaCode factorial needs to use longs

Russel Winder russel at winder.org.uk
Sun Mar 9 04:50:40 PDT 2014


On Sun, 2014-03-09 at 10:28 +0000, bearophile wrote:
> Russel Winder:
> 
> > That page appears to quietly ignore the fact that those 
> > languages that
> > use hardware integers cannot correctly compute factorial(25),
> 
> The D entry has the same problem. But a pre-condition could be 
> added to limit the input.

I think leaving the code as is, my point was that the whole page has the
problem that most of the implementation aren't actually useful in
practice, even though for any combinatoric problem (cf. bioinformatics,
quant calculations, etc.) this is a rather important function to get
right :-)

> 
> > I wonder though if it would be better to split the examples up 
> > rather
> > than have a single entry. Nothing to do with the code content 
> > just to do
> > with the visual perception. The D code looks big and so bad, 
> > whereas
> > those that split up the examples look small and so good. Can I 
> > suggest
> > partitioning the D entry into four sub entries so as to make it 
> > clear
> > that explicit iteration, implicit iteration, recursion and tail
> > recursion are all covered?
> 
> OK, I will split the D entry in four parts, but I think an 
> average programmer is able to see that code is made of four 
> separated functions that do the same thing in different ways and 
> it's not a single large chunk of code needed to do the task. 
> That's why I didn't bother with four entries.

I don't disagree, any half-way competent programmer should certainly
read it that way. The problem is that when scrolling down the page, the
visual impact is far more important for attention grabbing than the
content itself.

> (In Rosettacode some D entries are designed to be very short and 
> sweet, other to be very fast, other to show the kind of elaborate 
> code full of static typing and run-time tests you use in a piece 
> of code that should be correct, and so on. So the code style 
> varies on purpose to show various ways to write D. You can see 
> this in the N-Queens problem D entries and elsewhere).

It might be a good move to collect together all the URLs of codes like
this so that there is a quick way of reviewing and providing feedback.
Minimizing effort to do reviewing makes it more likely to happen. 

-- 
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: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140309/88e4e03b/attachment.sig>


More information about the Digitalmars-d-learn mailing list