Another cool mini-project: advance a range within n steps from its end
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Fri Dec 4 14:53:01 PST 2015
On 12/04/2015 04:26 PM, wobbles wrote:
> r.retro.take(n).retro seems like the easiest fit.
Doesn't work. Try it!
The right solution is to send a scout range ahead. Once the scout got n
steps ahead the initial range, advance both until the scout reaches the
end. Then return the initial range.
It's a nontrivial algorithm that can't be composed easily from existing
ones.
Andrei
More information about the Digitalmars-d
mailing list