3
$\begingroup$

The function b[c_] has been previously defined. Does that "1" refer to the smallest number of a list?

$\endgroup$
  • $\begingroup$ See mathematica.stackexchange.com/a/25616/193 $\endgroup$ – Michael E2 Jun 14 at 19:10
  • 1
    $\begingroup$ Actually, "1" refers to the first element of a list, not the smallest number of a list. Thus a[[1]] is the same as First[a]. $\endgroup$ – Somos Jun 14 at 23:49
7
$\begingroup$

If you just want to know what the double brackets mean, you can highlight them and use help. Or, you can use Information (?), for example:

?[[

enter image description here

Or, you can use Hold with FullForm to figure out what it means:

a /. b[c][[1]] //Hold //FullForm

Hold[ReplaceAll[a,Part[b[c],1]]]

$\endgroup$
1
$\begingroup$

Yes, 1 refers to the first element of the list. "/." is a rule replacement so I presume in this case that function "b" is returning a list of rules, which the line of code intends to use as a replacement operator for a.

Starting list or array notation at "1" is sometimes confusing for people used to "c" starting indices at 0. Note that there is a form of "Mod" that will properly provide the right index so you don't end up with "0" when you try to get a part of a list.

$\endgroup$

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