1
$\begingroup$

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.

$\endgroup$
3
  • 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$ – Mike Colacino 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
3
$\begingroup$

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}}
$\endgroup$
2
  • 2
    $\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.