Difference between revisions of "Insert Command"

From GeoGebra Manual
Jump to: navigation, search
Line 2: Line 2:
 
{{command|list}}
 
{{command|list}}
 
; Insert[Object, List, Position]: Inserts the object in the list at the given position.
 
; Insert[Object, List, Position]: Inserts the object in the list at the given position.
: {{Example| <code>Insert[x^2, {1, 2, 3, 4, 5}, 3]</code> places ''x<sup>2</sup>'' at the third position and gives you the list ''{1, 2, x<sup>2</sup>, 3, 4, 5}''.}}
+
: {{Example|1=<code>Insert[x^2, {1, 2, 3, 4, 5}, 3]</code> places ''x<sup>2</sup>'' at the third position and gives you the list ''{1, 2, x<sup>2</sup>, 3, 4, 5}''.}}
 
: {{Note| If the position is a negative number, then the position is counted from the right.}}
 
: {{Note| If the position is a negative number, then the position is counted from the right.}}
: {{Example| <code>Insert[x^2, {1, 2, 3, 4, 5}, -1]</code> places ''x<sup>2</sup>'' at the end of the list and gives you the list ''{1, 2, 3, 4, 5, x<sup>2</sup>}''.}}
+
: {{Example|1=<code>Insert[x^2, {1, 2, 3, 4, 5}, -1]</code> places ''x<sup>2</sup>'' at the end of the list and gives you the list ''{1, 2, 3, 4, 5, x<sup>2</sup>}''.}}
  
 
; Insert[List 1, List 2, Position]: Inserts all elements of ''list1'' in ''list2'' at the given position.
 
; Insert[List 1, List 2, Position]: Inserts all elements of ''list1'' in ''list2'' at the given position.
: {{Example| <code>Insert[{11, 12}, {1, 2, 3, 4, 5}, 3]</code> places the elements of ''list1'' at the third (and following) position(s) of ''list2'' and gives you the list ''{1, 2, 11, 12, 3, 4, 5}''.}}
+
: {{Example|1=<code>Insert[{11, 12}, {1, 2, 3, 4, 5}, 3]</code> places the elements of ''list1'' at the third (and following) position(s) of ''list2'' and gives you the list ''{1, 2, 11, 12, 3, 4, 5}''.}}
 
: {{Note| If the position is a negative number, then the position is counted from the right.}}
 
: {{Note| If the position is a negative number, then the position is counted from the right.}}
: {{Example| <code>Insert[{11, 12}, {1, 2, 3, 4, 5}, -2]</code> places the elements of ''list1'' at the end of ''list2'' before its last element and gives you ''{1, 2, 3, 4, 11, 12, 5}''.}}
+
: {{Example|1=<code>Insert[{11, 12}, {1, 2, 3, 4, 5}, -2]</code> places the elements of ''list1'' at the end of ''list2'' before its last element and gives you ''{1, 2, 3, 4, 11, 12, 5}''.}}

Revision as of 04:00, 17 April 2011


Insert[Object, List, Position]
Inserts the object in the list at the given position.
Example: Insert[x^2, {1, 2, 3, 4, 5}, 3] places x2 at the third position and gives you the list {1, 2, x2, 3, 4, 5}.
Note: If the position is a negative number, then the position is counted from the right.
Example: Insert[x^2, {1, 2, 3, 4, 5}, -1] places x2 at the end of the list and gives you the list {1, 2, 3, 4, 5, x2}.


Insert[List 1, List 2, Position]
Inserts all elements of list1 in list2 at the given position.
Example: Insert[{11, 12}, {1, 2, 3, 4, 5}, 3] places the elements of list1 at the third (and following) position(s) of list2 and gives you the list {1, 2, 11, 12, 3, 4, 5}.
Note: If the position is a negative number, then the position is counted from the right.
Example: Insert[{11, 12}, {1, 2, 3, 4, 5}, -2] places the elements of list1 at the end of list2 before its last element and gives you {1, 2, 3, 4, 11, 12, 5}.
© 2024 International GeoGebra Institute