Difference between revisions of "IndexOf Command"
From GeoGebra Manual
(added '' formatting) |
m (spacing) |
||
Line 2: | Line 2: | ||
{{command|list}} | {{command|list}} | ||
;IndexOf[ <Object>, <List> ] | ;IndexOf[ <Object>, <List> ] | ||
− | :Returns position of first occurrence of Object in List, e.g. <code>IndexOf[5,{1,3,5,2,5,4}]</code> returns 3. When the object is not found, result is ''undefined''. | + | :Returns position of first occurrence of Object in List, e.g. <code>IndexOf[5, {1, 3, 5, 2, 5, 4}]</code> returns 3. When the object is not found, result is ''undefined''. |
;IndexOf[ <Object>, <List>, <Start Index> ] | ;IndexOf[ <Object>, <List>, <Start Index> ] | ||
:Same as above, but the search starts at given index. | :Same as above, but the search starts at given index. | ||
{{example|1=<div> | {{example|1=<div> | ||
− | * <code>IndexOf[5,{1,3,5,2,5,4},3]</code> returns 3. | + | * <code>IndexOf[5, {1, 3, 5, 2, 5, 4}, 3]</code> returns 3. |
− | * <code>IndexOf[5,{1,3,5,2,5,4},4]</code> returns 5. | + | * <code>IndexOf[5, {1, 3, 5, 2, 5, 4}, 4]</code> returns 5. |
− | * <code>IndexOf[5,{1,3,5,2,5,4},6]</code> returns ''undefined''.</div>}} | + | * <code>IndexOf[5, {1, 3, 5, 2, 5, 4}, 6]</code> returns ''undefined''.</div>}} |
;IndexOf[ <Text Needle>, <Text Haystack>] | ;IndexOf[ <Text Needle>, <Text Haystack>] | ||
− | :Returns position of first occurrence of Needle in Haystack, e.g. <code>IndexOf["Ge","GeoGebra"]</code> returns 1. | + | :Returns position of first occurrence of Needle in Haystack, e.g. <code>IndexOf["Ge", "GeoGebra"]</code> returns 1. |
;IndexOf[ <Text Needle>, <Text Haystack>, <Start Index> ] | ;IndexOf[ <Text Needle>, <Text Haystack>, <Start Index> ] | ||
:Same as above, but the search starts at given index. | :Same as above, but the search starts at given index. | ||
− | {{example|1=<code>IndexOf["Ge","GeoGebra",2]</code> returns 4.}} | + | {{example|1=<code>IndexOf["Ge", "GeoGebra",2]</code> returns 4.}} |
Revision as of 12:00, 25 February 2013
- IndexOf[ <Object>, <List> ]
- Returns position of first occurrence of Object in List, e.g.
IndexOf[5, {1, 3, 5, 2, 5, 4}]
returns 3. When the object is not found, result is undefined. - IndexOf[ <Object>, <List>, <Start Index> ]
- Same as above, but the search starts at given index.
Example:
IndexOf[5, {1, 3, 5, 2, 5, 4}, 3]
returns 3.IndexOf[5, {1, 3, 5, 2, 5, 4}, 4]
returns 5.IndexOf[5, {1, 3, 5, 2, 5, 4}, 6]
returns undefined.
- IndexOf[ <Text Needle>, <Text Haystack>]
- Returns position of first occurrence of Needle in Haystack, e.g.
IndexOf["Ge", "GeoGebra"]
returns 1. - IndexOf[ <Text Needle>, <Text Haystack>, <Start Index> ]
- Same as above, but the search starts at given index.
Example:
IndexOf["Ge", "GeoGebra",2]
returns 4.