On 7/24/12 1:10 PM, Russel Winder wrote:
I am wondering if the examples at
http://dlang.org/phobos/std_range.html#take need some attention. As far
as I can see they only work because the input is a list. If you take
from the result of an algorithm such as recurrence then you have to
explicitly create an array from the result of the take in order for the
[] operator to be defined.

The example is:

int[] arr1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
auto s = take(arr1, 5);
assert(s.length == 5);
assert(s[4] == 5);
assert(equal(s, [ 1, 2, 3, 4, 5 ][]));

Were you referring to this? Example code does not need to be generic, and in this case it's fine if the code relies on random access because it uses an array of integers.


Andrei


Reply via email to