# A Novice question about slicing operation

【】I have an index matrix
A = torch.tensor([[1, 3], [2, 5], [4, 7]])
【】I have a vector，too
B = torch.tensor([10, 20, 30, 40, 50, 60])
【】but how can i got a slice like this？ (#_#)↓
C=B[A[:, 0]:A[:, 1]]

Hi Ashawojiangkele!

If I understand correctly what you want to do, you can’t do this with pytorch
tensors.

It looks like you want the first row of `C` to be the 1 and 2 elements of `B`, that is,
`B[1]` and `B[2]`, you want the second row of `C` to be the 2, 3, and 4 elements,
and so on. That is, you want the rows of `C` to have differing lengths.

The problem is that pytorch does not support such “ragged” tensors where
rows (or columns, etc.) don’t all have the same length.

As an aside, `B` has length 6 (elements `B[0], ..., B[5]`), so if you did what
you wanted, the third row of `A`, `[4, 7]`, would only slice out two elements
(elements 4 and 5) because no element 6 exists. (`B[5] = 60` and `B[6]` would
give you an index-out-of-bounds error).

Best.

K. Frank