2
$\begingroup$

I am trying to solve a practical research problem, that is I need to select element in a specific position with the same offset, for example: select the second element in every three elements among the nested list: {{a,b,c,1,2,3},{e,f,g,4,5,6},...}, so in this example, we would get a new list: {{b,2},{f,5},...} so this example is a simple one, I want to implement this to broader problems such as manipulating nested list with larger dimensions. And the offset might be differ.

I was trying to use Select or Part to solve this problem. Because for handling with 'position' stuff, Part works well. But both of them seems not support nested list manipulating that need to set an offset? Correct me if I were misunderstanding them please.

$\endgroup$

1 Answer 1

3
$\begingroup$
list = {{a, b, c, 1, 2, 3}, {e, f, g, 4, 5, 6}, ...};
list[[All, 2 ;; ;; 3]]
{{b, 2}, {f, 5}, ...}
$\endgroup$
1
  • $\begingroup$ This one works great! Thanks for your help! $\endgroup$
    – cj9435042
    Commented Jan 6, 2018 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.