Difference between revisions of "First Command"
From GeoGebra Manual
Line 2: | Line 2: | ||
{{command|list}} | {{command|list}} | ||
;First[ <List L> ] | ;First[ <List L> ] | ||
− | : | + | :Gives a list containing the first element of the list ''L''. |
− | {{example|1=<div><code><nowiki>First[{1, | + | {{example|1=<div><code><nowiki>First[{1, 4, 3}]</nowiki></code> returns ''{1}''.</div>}} |
To get the first element itself use e.g. [[Element Command]]. | To get the first element itself use e.g. [[Element Command]]. | ||
;First[ <List L>, <Number n of elements> ] | ;First[ <List L>, <Number n of elements> ] | ||
− | : | + | :Gives a new list that contains just the first ''n'' elements of the list ''L''. |
;First[ <Text> ] | ;First[ <Text> ] | ||
− | : | + | :Gives first character of the text. |
;First[ <Text> , <Number n of elements> ] | ;First[ <Text> , <Number n of elements> ] | ||
− | : | + | :Gives the first ''n'' characters of the text. |
{{example|1=<div><code><nowiki>First["Hello",2]</nowiki></code> returns "He".</div>}} | {{example|1=<div><code><nowiki>First["Hello",2]</nowiki></code> returns "He".</div>}} | ||
;First[ <Locus>, <Number n of elements> ] | ;First[ <Locus>, <Number n of elements> ] | ||
Line 18: | Line 18: | ||
==CAS Syntax== | ==CAS Syntax== | ||
;First[ <List L> ] | ;First[ <List L> ] | ||
− | : | + | :Gives a list containing the first element of the list ''L''. |
− | {{example|1=<div><code><nowiki>First[{1, | + | {{example|1=<div><code><nowiki>First[{1, 4, 3}]</nowiki></code> returns ''{1}''.</div>}} |
To get the first element itself use e.g. [[Element Command]]. | To get the first element itself use e.g. [[Element Command]]. | ||
;First[ <List L>, <Number n of elements> ] | ;First[ <List L>, <Number n of elements> ] | ||
− | : | + | :Gives a new list that contains just the first ''n'' elements of the list ''L''. |
+ | {{example|1=<div><code><nowiki>First[{1, 4, 3}, 2]</nowiki></code> returns ''{1, 2}''.</div>}} |
Revision as of 11:52, 5 August 2011
- First[ <List L> ]
- Gives a list containing the first element of the list L.
Example:
First[{1, 4, 3}]
returns {1}.To get the first element itself use e.g. Element Command.
- First[ <List L>, <Number n of elements> ]
- Gives a new list that contains just the first n elements of the list L.
- First[ <Text> ]
- Gives first character of the text.
- First[ <Text> , <Number n of elements> ]
- Gives the first n characters of the text.
Example:
First["Hello",2]
returns "He".- First[ <Locus>, <Number n of elements> ]
- This command is useful for
- loci generated by SolveODE Command - It returns list points that were created in the first n steps of the numeric ODE-solving algorithm.
- loci generated using ShortestDistance Command, TravelingSalesman Command, Voronoi Command, MinimumSpanningTree Command, ConvexHull Command and Hull Command Commands - it returns vertices of the graph
CAS Syntax
- First[ <List L> ]
- Gives a list containing the first element of the list L.
Example:
First[{1, 4, 3}]
returns {1}.To get the first element itself use e.g. Element Command.
- First[ <List L>, <Number n of elements> ]
- Gives a new list that contains just the first n elements of the list L.
Example:
First[{1, 4, 3}, 2]
returns {1, 2}.