Remove - Maple Help

ArrayTools

 Remove
 remove entries and shrink an Array

 Calling Sequence Remove( A, i) Remove( A, a..b)

Parameters

 A - 1-D Array or Vector i, a, b - integer index

Description

 • The Remove command deletes the entries at index i, or index range a..b.  After this operation, upperbound(A) will be smaller by the number of elements deleted.
 • If A is an array or vector with an index range starting at zero or higher, then negative indexing can be used to specify the index to remove.  For example, Remove(A,-1), will remove the last element, and Remove(A,-2..-1) will remove the last two elements.
 • This operation works in-place and will cause all references to A to be modified accordingly.
 • The Remove command only works on 1-D Arrays and Vectors with rectangular dense storage and no indexing function.
 • This function is part of the ArrayTools package, so it can be used in the short form Remove(..) only after executing the command with(ArrayTools). However, it can always be accessed through the long form of the command by using ArrayTools[Remove](..).

Examples

 > $\mathrm{with}\left(\mathrm{ArrayTools}\right):$
 > $A≔\mathrm{Array}\left(\left[11,22,33,44,55\right]\right)$
 ${A}{≔}\left[\begin{array}{ccccc}{11}& {22}& {33}& {44}& {55}\end{array}\right]$ (1)

Remove A[3] and shrink:

 > $\mathrm{Remove}\left(A,3\right)$
 $\left[\begin{array}{cccc}{11}& {22}& {44}& {55}\end{array}\right]$ (2)

A is permanently changed:

 > $A$
 $\left[\begin{array}{cccc}{11}& {22}& {44}& {55}\end{array}\right]$ (3)
 > $\mathrm{upperbound}\left(A\right)$
 ${4}$ (4)
 > $\mathrm{ArrayDims}\left(A\right)$
 ${1}{..}{4}$ (5)
 > $\mathrm{numelems}\left(A\right)$
 ${4}$ (6)

Remove a range of elements

 > $\mathrm{Remove}\left(A,1..2\right)$
 $\left[\begin{array}{cc}{44}& {55}\end{array}\right]$ (7)

Remove the last element

 > $\mathrm{Remove}\left(A,-1\right)$
 $\left[\begin{array}{c}{44}\end{array}\right]$ (8)

 > $A\left(2\right)≔55$
 ${A}{}\left({2}\right){≔}\left[\begin{array}{cc}{44}& {55}\end{array}\right]$ (9)
 > $A\left(3\right)≔66$
 ${A}{}\left({3}\right){≔}\left[\begin{array}{ccc}{44}& {55}& {66}\end{array}\right]$ (10)
 > $A$
 $\left[\begin{array}{ccc}{44}& {55}& {66}\end{array}\right]$ (11)

Remove the last two elements

 > $\mathrm{Remove}\left(A,-2..-1\right)$
 $\left[\begin{array}{c}{44}\end{array}\right]$ (12)

Compatibility

 • The ArrayTools[Remove] command was introduced in Maple 2019.