Difference between revisions of "IndexOf Command"

From GeoGebra Manual
Jump to: navigation, search
m
(command syntax: changed [ ] into ( ))
 
Line 1: Line 1:
 
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|list}}
 
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|list}}
;IndexOf[ <Object>, &lt;List> ]
+
;IndexOf( <Object>, &lt;List> )
 
:Returns position of first occurrence of Object in List.
 
:Returns position of first occurrence of Object in List.
:{{examples|1=<code>IndexOf[5, {1, 3, 5, 2, 5, 4}]</code> returns ''3''.}}
+
:{{examples|1=<code>IndexOf(5, {1, 3, 5, 2, 5, 4})</code> returns ''3''.}}
 
:{{note| 1=When the object is not found, result is ''undefined''.}}
 
:{{note| 1=When the object is not found, result is ''undefined''.}}
 
<br>
 
<br>
;IndexOf[ <Object>, &lt;List>, <Start Index> ]
+
;IndexOf( <Object>, &lt;List>, <Start Index> )
 
:Same as above, but the search starts at given index.
 
:Same as above, but the search starts at given index.
 
:{{examples|1=<div>
 
:{{examples|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>, <Text> ]
+
;IndexOf( <Text>, <Text> )
 
:Specifies the position at which the short text appears for the first time in the whole text.
 
:Specifies the position at which the short text appears for the first time in the whole text.
:{{example|1=<code>IndexOf["Ge", "GeoGebra"]</code> returns ''1''.}}
+
:{{example|1=<code>IndexOf("Ge", "GeoGebra")</code> returns ''1''.}}
 
<br>
 
<br>
;IndexOf[ <Text>, <Text>, <Start Index> ]
+
;IndexOf( <Text>, <Text>, <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''.}}

Latest revision as of 11:18, 6 October 2017


IndexOf( <Object>, <List> )
Returns position of first occurrence of Object in List.
Examples: IndexOf(5, {1, 3, 5, 2, 5, 4}) returns 3.
Note: When the object is not found, result is undefined.


IndexOf( <Object>, <List>, <Start Index> )
Same as above, but the search starts at given index.
Examples:
  • 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>, <Text> )
Specifies the position at which the short text appears for the first time in the whole text.
Example: IndexOf("Ge", "GeoGebra") returns 1.


IndexOf( <Text>, <Text>, <Start Index> )
Same as above, but the search starts at given index.
Example: IndexOf("Ge", "GeoGebra",2) returns 4.
© 2024 International GeoGebra Institute