Difference between revisions of "Element Command"
From GeoGebra Manual
Line 3: | Line 3: | ||
; Element[List, Number n]: Yields the ''n''<sup>th</sup> element of the list. | ; Element[List, Number n]: Yields the ''n''<sup>th</sup> element of the list. | ||
; Element[Matrix, Row, Column]: Yields the element of the matrix in the given row and column. | ; Element[Matrix, Row, Column]: Yields the element of the matrix in the given row and column. | ||
− | |||
; Element[List L, Index1, Index2, ...] | ; Element[List L, Index1, Index2, ...] | ||
: Provided L is ''n''-dimensional list, one can specify up to ''n'' indices to obtain an element (or list of elements) at given coordinates. | : Provided L is ''n''-dimensional list, one can specify up to ''n'' indices to obtain an element (or list of elements) at given coordinates. | ||
{{Example|1=Let <nowiki>L={{{1,2},{3,4}},{{5,6},{7,8}}}</nowiki>. Then <code>Element[L,1,2,1]</code> returns 3, <code>Element[L,2,2]</code> returns {7,8}.}} | {{Example|1=Let <nowiki>L={{{1,2},{3,4}},{{5,6},{7,8}}}</nowiki>. Then <code>Element[L,1,2,1]</code> returns 3, <code>Element[L,2,2]</code> returns {7,8}.}} | ||
+ | : {{Note| For this command to work, the list or matrix can contain elements of one object type only (e. g., only numbers or only points.}} | ||
+ | ==Shorthand syntax== | ||
+ | To get ''i''-th element of list ''L'' expression ''L(i)'' can be used, in case of multidimensional lists one can use ''L(i1,i2,...,ik)'' instead of <code>Element[L,i1,i2,..,ik]</code> . Note that this syntax works only for labelled lists, syntax | ||
+ | <code>Element[Join[L,M],1,2,3]</code> is correct, but ''Join[L,M](1,2,3)'' doesn't work. |
Revision as of 00:37, 22 July 2011
- Element[List, Number n]
- Yields the nth element of the list.
- Element[Matrix, Row, Column]
- Yields the element of the matrix in the given row and column.
- Element[List L, Index1, Index2, ...]
- Provided L is n-dimensional list, one can specify up to n indices to obtain an element (or list of elements) at given coordinates.
Example: Let L={{{1,2},{3,4}},{{5,6},{7,8}}}. Then
Element[L,1,2,1]
returns 3, Element[L,2,2]
returns {7,8}.- Note: For this command to work, the list or matrix can contain elements of one object type only (e. g., only numbers or only points.
Shorthand syntax
To get i-th element of list L expression L(i) can be used, in case of multidimensional lists one can use L(i1,i2,...,ik) instead of Element[L,i1,i2,..,ik]
. Note that this syntax works only for labelled lists, syntax
Element[Join[L,M],1,2,3]
is correct, but Join[L,M](1,2,3) doesn't work.