Message Boards Message Boards

0
|
6882 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How do I take multiples elements depending on their position?

Hi, I have

resu = {{a,b,c,d},{g,e,f,h,r,d}}

pos = {3, 2}

I want to Take the elements in the position 3 of resu[[1]] and the second position element in resu[[2]]. So I have written

cp = **Table[Take[resu[[i]],{1, pos[[i]] }  &], {i, 1, Length[pos]}]**

But it isn't right. Where is the problem? Thank you for your help.

Margherita

3 Replies

Thank you!

Hi,

this command is similar to your idea:

cp = Flatten[Table[Take[resu[[i]], {pos[[i]]}], {i, 1, Length[pos]}]]

Cheers,

Marco

POSTED BY: Marco Thiel
Extract[resu, {{1, 3}, {2, 2}}]

{c, e}

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract