 Insert - Maple Help

ArrayTools

 Insert Calling Sequence Insert(A,pos,expr,opts) Parameters

 A - Array or Vector pos - position to insert expr - expression to insert opts - (optional) inplace=true or inplace=false Options

 • inplace = true or false
 Specifies whether the insert operation should reuse the existing Array or generate a new Array. The default value is true. Description

 • The Insert(A,pos,expr) command inserts the expression expr into the Vector or the 1-D Array A at the position pos.
 • If there is already a value at position pos, this value and all remaining values are shifted rightwards in the array.
 • If the position pos is beyond the bounds of the array, then the array's size will be increased and any new elements in between exisiting elements and the inserted entry will be initialized to zero.
 • When inplace=false is specified, the insert operation allocates a new Array and does not modify the existing one.  Otherwise, the existing object is modified.
 • This function is part of the ArrayTools package, so it can be used in the short form Insert(..) only after executing the command with(ArrayTools). However, it can always be accessed through the long form of the command by using ArrayTools[Insert](..). Examples

 > $\mathrm{with}\left(\mathrm{ArrayTools}\right):$
 > $A≔\mathrm{Array}\left(\left[2,3,5\right]\right)$
 ${A}{≔}\left[\begin{array}{ccc}{2}& {3}& {5}\end{array}\right]$ (1)
 > $\mathrm{Insert}\left(A,2,\frac{1}{x}\right)$
 $\left[\begin{array}{cccc}{2}& \frac{{1}}{{x}}& {3}& {5}\end{array}\right]$ (2)
 > $\mathrm{Insert}\left(A,3,\mathrm{sin}\left(x\right)\right)$
 $\left[\begin{array}{ccccc}{2}& \frac{{1}}{{x}}& {\mathrm{sin}}{}\left({x}\right)& {3}& {5}\end{array}\right]$ (3)
 > $v≔⟨1,2x⟩$
 ${v}{≔}\left[\begin{array}{c}{1}\\ {2}{}{x}\end{array}\right]$ (4)
 > $\mathrm{Insert}\left(v,2,3{x}^{2},\mathrm{inplace}=\mathrm{false}\right)$
 $\left[\begin{array}{c}{1}\\ {3}{}{{x}}^{{2}}\\ {2}{}{x}\end{array}\right]$ (5)
 > $v$
 $\left[\begin{array}{c}{1}\\ {2}{}{x}\end{array}\right]$ (6)
 > $\mathrm{A2}≔\mathrm{Array}\left(-3..-2,\left[7,8\right]\right)$
 ${\mathrm{A2}}{≔}\left[{7}{,}{8}{,}{\text{⋯ -3 .. -2 Array}}\right]$ (7)
 > $\mathrm{Insert}\left(\mathrm{A2},-3,6\right)$
 $\left[{6}{,}{7}{,}{8}{,}{\text{⋯ -3 .. -1 Array}}\right]$ (8)
 > $\mathrm{A2}\left[-3\right]$
 ${6}$ (9) Compatibility

 • The ArrayTools[Insert] command was introduced in Maple 2016.