On Wednesday, 11 June 2014 at 11:50:36 UTC, Andrew Brown wrote:

map is fully lazy.

However, if you've already got the sorted indices in `order`, I would do this:

auto numLessThanN = numbers.indexed(order).countUntil!((x) => x
>= N)();

That indexed command is perfect though, does the trick, thank you very much.

For future reference: map applies its predicate in `front`, meaning that

a) It is completely lazy, you only pay for elements you actually access.

b) Unless the optimiser is smart and caches the result for you, you pay every time you call `front`, even if you haven't called `popFront` in between.

Reply via email to