I have a table, for example given by Table[{{1,8},{3,9},{5,10},{6,30},{10,70}}]. How can I select a part of this table so that the result takes the form {{5,10},{6,30}}?. I will be really thankful if someone help.


closed as off-topic by Edmund, Bob Hanlon, Henrik Schumacher, m_goldberg, MarcoB Jul 7 '18 at 4:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Edmund, Bob Hanlon, Henrik Schumacher, m_goldberg, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Table is used to construct tables via iteration. I think what you are looking for is a list, which you have already constructed inside your syntactically incorrect Table function call. Then you can use MMA's standard Part syntax. For example {{1, 8}, {3, 9}, {5, 10}, {6, 30}, {10, 70}}[[3;;4]] $\endgroup$ – mdc18550 Jul 6 '18 at 20:38
  • $\begingroup$ Incorrect syntax. Please reference what Table does. Also, see Part. $\endgroup$ – Edmund Jul 6 '18 at 20:39
  • 1
    $\begingroup$ @mdc18550 Yes you are right and this answer is correct. My table is very large and the table mentioned above just was an example to ask my question. Thank you very much. $\endgroup$ – Mehrab Jul 6 '18 at 21:01

Use the Part function to select the 3rd and 4th parts.

Part[{{1,8},{3,9},{5,10},{6,30},{10,70}}, {3,4}]

or using the "[[" shorthand,

{{1,8},{3,9},{5,10},{6,30},{10,70}}[[{3, 4}]]

Both of these return

{{5, 10}, {6, 30}}
  • 1
    $\begingroup$ Or Part with Span: table[[3 ;; 4]] $\endgroup$ – Bob Hanlon Jul 6 '18 at 20:42
  • $\begingroup$ Please add the comment of mdc18550 mentioned above as answer of this question. $\endgroup$ – Mehrab Jul 6 '18 at 21:04

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