how implement takeWhile

Philippe Sigaud philippe.sigaud at gmail.com
Mon Aug 6 08:32:43 PDT 2012


On Mon, Aug 6, 2012 at 3:17 PM, Russel Winder <russel at winder.org.uk> wrote:

>> > Do a JVM backend to D and D could wipe the floor with Scala :-)
>>
>> Why is that? Can't Scala do the same?
>
> Scala can definitely do the same, possibly more, but it's syntax gets
> annoying and compilation time is horrendous.

>From what I know of Scala, for the OP qustion the syntax would be
about the same as D (that is, far more cluttered than Haskell). About
compilation time, I didn't know that. Do you happen to have some
personal experience on this? (this is not a quip, just an honest
question).

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?


As for the OP question, use std.algo.until as your takeWhile, as Simen
showed. I also coded takeWhile in a D a few years ago, it's not
difficult and is a good exercice in range coding.


More information about the Digitalmars-d-learn mailing list