If I have an array myarray in Python, I can use the slice notation
myarray
myarray[0::2]
to select only the even-indexed elements. For
If you don't care about the order, and if the odd-numbered elements of the list are unique, you can concisely convert the array to a hash and take the values:
values
@even_elements = values %{{@array}}; @odd_elements = keys %{{@array}};
(No, this is not a serious answer)