On Sun, Jul 27, 2014 at 9:20 PM, H. S. Teoh via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
On Sun, Jul 27, 2014 at 07:42:17PM -0700, Timothee Cour via Digitalmars-d-learn wrote:
> Just for clarification, I wanted 'myrange.at(i)' to be the same as
> `myrange.dropExactly(i).front`
> (so I don't assume it's a random access range).
>
> >> myrange.dropExactly(i).front makes it much more obvious what you're
> doing and that it's inefficient. It might be necessary in some cases,
> but we don't want to give the impression that it's cheap, which at()
> would do.
>
> I think it's already clear that it's potentially O(n) [n=i] cost as
> we're not using myrange[i]. But fine, call it atWalk/walkAt/whatever.
> Point is it's a common enough operation.
[...]

You could just define your own function for it, right?

        // or call it whatever you want
        auto getNth(R)(R range, size_t index)
                if (isInputRange!R)
        {
                return range.dropExactly(index).front;
        }


T

--
Making non-nullable pointers is just plugging one hole in a cheese grater. -- Walter Bright


Obviously I did that, but I thought it belonged in phobos. Anyway, closing this.