I have a large set of elements, and I want to extract elements from it. I need to skip some elements from the beginning, and some from the end.
The following example is simplified.
At first I tried to extract the bounding elements:
> ("a", "b", "c", "d", "e")[1,-2]
b
d
This works as expected.
However, when I tried to extract the entire range, it returns something else than I want (unlike Python ['a', 'b', 'c', 'd', 'e'][1:-1], which works well).
> ("a", "b", "c", "d", "e")[1..-2]
b
a
e
d
He turns the other way. How to change the direction of the loop?
I want to get: b c d.
Is there a solution without using the real length of the collection?
source
share