For example, I have x ={11,12,13,14}, how do I get the element staying at the third place, that is, 13?
Asked
Active
Viewed 685 times
1 Answers
2
Use double square brackets to point at the element staying at the nth place, x[[3]] will produce the element staying in the third-place counting from 1 for the beginning of the list. In the example, it is 13. {11,12,13,14}[[1]] will produce 11 and {11,12,13,14}[[4]] equals Last[{11,12,13,14},that is, 14.
Errdonald
- 39
- 3
-
1This Q&A could (should?) go into What are the most common pitfalls awaiting new users? – user1066 Jan 05 '22 at 04:17
-
Sure, I visited the link and there is a discussion of double bracket access to the lists, thank you! – Errdonald Jan 05 '22 at 07:35
Extract. For exampleExtract[3] @ xwould extract the third element of list $x$. – LouisB Jan 03 '22 at 23:12Part. – Carl Lange Jan 04 '22 at 20:43