On Fri, 06 Aug 2010 14:59:17 -0400, Philippe Sigaud <philippe.sig...@gmail.com> wrote:

On Fri, Aug 6, 2010 at 19:48, Steven Schveighoffer <schvei...@yahoo.com>wrote:

On Fri, 06 Aug 2010 13:33:09 -0400, Philippe Sigaud <
philippe.sig...@gmail.com> wrote:

Here is what I cooked, it's still a bit rough around the edges. It has an
optional step argument, to see how many elements to jump.


[snip]


ElementType!R[] front() @property { return array(take(range, n));} //


I'd change this to just return take(range, n).  Rule #1 in writing
efficient D code, avoid the heap when you can :)


Hmm, good idea. And that way, if n is big, you get a lazy range. But you
lose the random access and such. I guess the user will call map!array() if
she wants to get arrays?

Doesn't take return a random-access range if the original is a random access range?

I would actually expect take(range, n) to return range[0..n] if range supports that.

-Steve

Reply via email to