Last element of a forward range

bearophile bearophileHUGS at lycos.com
Sat Apr 12 03:26:58 PDT 2014


Steven Schveighoffer:

> Interesting problem.

And it's not an academic one, I have already faced it two or 
three times :-)


> Given that it is a forward range, a zip between it and a saved 
> copy that is advanced by one may work.

This compiles and gives the expected output, but how do you 
extract the last item with this?

seq.zip(seq.dropOne).writeln;

I have written I've added an ER to Phobos with some preliminary 
code:
https://issues.dlang.org/show_bug.cgi?id=12564

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list