Difference between revisions of "Element Command"

From GeoGebra Manual
Jump to: navigation, search
m (changed CAS syntax description)
Line 1: Line 1:
<noinclude>{{Manual Page|version=5.0}}</noinclude>
+
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|cas=true|list}}
{{command|cas=true|list}}
+
;Element[ <List>, <Position of Element n> ]
;Element[ &lt;List>, <Position of Element n> ]
 
 
:Yields the ''n''<sup>th</sup> element of the list.
 
:Yields the ''n''<sup>th</sup> element of the list.
 
:{{example| 1=<div><code><nowiki>Element[{1, 3, 2}, 2]</nowiki></code> yields ''3'', the second element of ''{1, 3, 2}''.</div>}}
 
:{{example| 1=<div><code><nowiki>Element[{1, 3, 2}, 2]</nowiki></code> yields ''3'', the second element of ''{1, 3, 2}''.</div>}}
 +
:{{note|1=
 +
In the [[File:Menu view cas.svg|link=|16px]] [[CAS View]] undefined variables can be used as well.
 +
::{{example| 1=<div><code><nowiki>Element[{a, b, c}, 2]</nowiki></code> yields  ''b'', the second element of ''{a, b, c}''.</div>}}
 +
}}
 
;Element[ <Matrix>, <Row>, <Column> ]
 
;Element[ <Matrix>, <Row>, <Column> ]
 
:Yields the element of the matrix in the given row and column.
 
:Yields the element of the matrix in the given row and column.
 
:{{example| 1=<div><code><nowiki>Element[{{1, 3, 2}, {0, 3, -2}}, 2, 3]</nowiki></code> yields ''-2'', the third element of the second row of <math>\begin{pmatrix}1&3&2\\0&3&-2\end{pmatrix}</math>.</div>}}
 
:{{example| 1=<div><code><nowiki>Element[{{1, 3, 2}, {0, 3, -2}}, 2, 3]</nowiki></code> yields ''-2'', the third element of the second row of <math>\begin{pmatrix}1&3&2\\0&3&-2\end{pmatrix}</math>.</div>}}
;Element[ &lt;List>, <Index1>, <Index2>,  ...]
+
:{{note|1=
 +
In the [[File:Menu view cas.svg|link=|16px]] [[CAS View]] undefined variables can be used as well.
 +
::{{example| 1=<div><code><nowiki>Element[{{a, b, c}, {d, e, f}}, 2, 3]</nowiki></code> yields ''f'', the third element of the second row of <math>\begin{pmatrix}a&b&c\\d&e&f\end{pmatrix}</math>.</div>}}
 +
}}
 +
;Element[ <List>, <Index1>, <Index2>,  ...]
 
:Provided list is ''n''-dimensional list, one can specify up to ''n'' indices to obtain an element (or list of elements) at given coordinates.
 
:Provided list is ''n''-dimensional list, one can specify up to ''n'' indices to obtain an element (or list of elements) at given coordinates.
 
:{{example|1=<div>Let ''<nowiki>L = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}</nowiki>''. <div>Then <code><nowiki>Element[L, 1, 2, 1]</nowiki></code> yields ''3'', <code><nowiki>Element[L, 2, 2]</nowiki></code> yields ''{7, 8}''.</div></div>}}
 
:{{example|1=<div>Let ''<nowiki>L = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}</nowiki>''. <div>Then <code><nowiki>Element[L, 1, 2, 1]</nowiki></code> yields ''3'', <code><nowiki>Element[L, 2, 2]</nowiki></code> yields ''{7, 8}''.</div></div>}}
{{note| 1=This command only works, if the list or matrix contains elements of one object type (e. g. only numbers or only points).}}
+
{{note| 1=
==CAS Syntax==
+
:*This command only works, if the list or matrix contains elements of one object type (e. g. only numbers or only points).
;Element[ &lt;List>, <Position of Element n> ]
+
:*<div>See also [[First Command]], [[Last Command]] and [[RandomElement Command]].</div>}}
:Yields the ''n''<sup>th</sup> element of the list.
 
:{{example| 1=<div><code><nowiki>Element[{a, b, c}, 2]</nowiki></code> yields  ''b'', the second element of ''{a, b, c}''.</div>}}
 
;Element[ <Matrix>, <Row>, <Column> ]
 
:Yields the element of the matrix in the given row and column.
 
:{{example| 1=<div><code><nowiki>Element[{{a, b, c}, {d, e, f}}, 2, 3]</nowiki></code> yields ''f'', the third element of the second row of<math>\begin{pmatrix}a&b&c\\d&e&f\end{pmatrix}</math>.</div>}}
 
{{note| 1=<div>See also [[First Command]], [[Last Command]] and [[RandomElement Command]].</div>}}
 

Revision as of 14:16, 1 October 2015


Element[ <List>, <Position of Element n> ]
Yields the nth element of the list.
Example:
Element[{1, 3, 2}, 2] yields 3, the second element of {1, 3, 2}.
Note: In the Menu view cas.svg CAS View undefined variables can be used as well.
Example:
Element[{a, b, c}, 2] yields b, the second element of {a, b, c}.
Element[ <Matrix>, <Row>, <Column> ]
Yields the element of the matrix in the given row and column.
Example:
Element[{{1, 3, 2}, {0, 3, -2}}, 2, 3] yields -2, the third element of the second row of \begin{pmatrix}1&3&2\\0&3&-2\end{pmatrix}.
Note: In the Menu view cas.svg CAS View undefined variables can be used as well.
Example:
Element[{{a, b, c}, {d, e, f}}, 2, 3] yields f, the third element of the second row of \begin{pmatrix}a&b&c\\d&e&f\end{pmatrix}.
Element[ <List>, <Index1>, <Index2>, ...]
Provided list 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] yields 3, Element[L, 2, 2] yields {7, 8}.
Note:
© 2024 International GeoGebra Institute