# WolframLang: Add Element to List

By Xah Lee. Date: . Last updated: .
• 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[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

`Append[expr, new]`

return a new expr with new item added at end.

`Append[ List[ 3, 4 ], 5 ] === {3, 4, 5}`
`AppendTo[x, elem]`

Same as `x=Append[x, elem]`

`Prepend`

`Prepend[ List[ 3, 4 ], 5 ] === { 5, 3, 4}`
`PrependTo[x, elem]`
Same as `x=Prepend[x, elem]`