0

For example, I have x ={11,12,13,14}, how do I get the element staying at the third place, that is, 13?

Errdonald
  • 39
  • 3
  • You might want use Extract. For example Extract[3] @ x would extract the third element of list $x$. – LouisB Jan 03 '22 at 23:12
  • 1
    Yes, and I expect there are many more ways to extract the nth element from the list! But the one with double square brackets is special because square brackets are commonly used to extract an element from a list or an array in programming languages but as a rule, other languages use ordinary square brackets for this purpose and this fact bewildered me and led to formulate my question here. – Errdonald Jan 04 '22 at 20:40
  • So you're aware, the double square bracket notation is a shortcut for Part. – Carl Lange Jan 04 '22 at 20:43

1 Answers1

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