WolframLang: Add Element to List
- Almost all Functions do not modify the argument or variable. They return a new value. If you want to modify the variable that hold a list, you assign it back. e.g.
listVar = f[ listVar ]
- Function whose name end in βToβ, (e.g.
AppendTo
) modifies the variable. (the argument must be a variable.)
Insert
Insert[list, elem, n]
-
Insert an element at n
same as
Insert[list, elem, {n}]
Insert[ {3, 4}, x, 2 ] === {3, x, 4}
Insert[list, elem, {i, j, k}]
-
- Insert an element at Position
{i, j, k}
- Return a new list. (Does not modify the list.)
Insert[ {3, 4}, x, {2} ] === {3, x, 4} Insert[ {3, {4}}, x, {2,1} ] === {3, {x, 4}}
- Insert an element at Position
Insert[list, elem, {pos1, pos2, etc }]
-
insert an element at several positions
Insert[ {{1,0}, {2,0}, {3,0}}, x, {{2}, {3,1}} ] === {{1, 0}, x, {2, 0}, {x, 3, 0}}
Append, Prepend
WolframLang List Operations
- WolframLang: List Operations
- WolframLang: Get Parts of List
- WolframLang: Add Element to List
- WolframLang: Delete Element in List
- WolframLang: Change Element in List
- WolframLang: Check Item Exist in List
- WolframLang: Filter List
- WolframLang: Sort, Reverse, Order
- WolframLang: List Reshape (split, group, flatten, transpose)
- WolframLang: List Combinatorics
- WolframLang: List Join, Union, Intersection, Difference