how implement takeWhile

Simen Kjaeraas simen.kjaras at gmail.com
Mon Aug 6 17:27:32 PDT 2012


On Mon, 06 Aug 2012 17:49:19 +0200, Philippe Sigaud  
<philippe.sigaud at gmail.com> wrote:

> On Mon, Aug 6, 2012 at 5:32 PM, Philippe Sigaud
> <philippe.sigaud at gmail.com> wrote:
>
>> What I'd like to know and may test myself is: is there any speed
>> difference in this functional-oriented D code and a more standard
>> (C-ish) way to obtain the same result?
>
> Here it is. Answer: no noticeable difference.

Great, but is that only because it goes too quickly anyways?

I changed it a bit to use BigInt in both places, and for a max of 2^512,
I got the following numbers, fairly consistently:

C:       139288 ns
Haskell: 165104 ns

About 20% difference. Not bad.


> The functional way also works at CT, that's great.
> Of course, the functional code is (to my eyes) easier to read, easier
> to debug and easier to modify.

Indeed.


-- 
Simen


More information about the Digitalmars-d-learn mailing list