and length, take offers them as well.
take
Lazily takes only up to n elements of a range. This is particularly useful when using with infinite ranges.
Unlike takeExactly, take does not require that there are n or more elements in input. As a consequence, length information is not applied to the result unless input also has length information.
Parameters
input | an input range to iterate over up to n times |
n | the number of elements to take |
Returns
At minimum, an input range. If the range offers random access