ArrayTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Low-level Manipulation : Matrices, Vectors, and Arrays : ArrayTools : ArrayTools/Insert

ArrayTools

  

Insert

  

insert an element in an Array

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

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 : keyword option of the form inplace=true or inplace=false. This specifies whether the insert operation should reuse the existing Array or generate a new Array.  Its 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

withArrayTools:

AArray2,3,5

A235

(1)

InsertA,2,1x

21x35

(2)

InsertA,3,sinx

21xsinx35

(3)

v1,2x

v12x

(4)

Insertv,2,3x2,inplace=false

13x22x

(5)

v

12x

(6)

A2Array3..2,7,8

A2Array−3..−2,−3=7,−2=8

(7)

InsertA2,3,6

Array−3..−1,−3=6,−2=7,−1=8

(8)

A23

6

(9)

Compatibility

• 

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

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

ArrayTools

ArrayTools[Append]

ArrayTools[Extend]