delete

delete — removes an element from an array.

Syntax

delete (array, position)

		

Arguments

array

An array.

position

An integer giving the zero-indexed position of the array element to delete.

Returns

The deleted array element, or nil if none was deleted. The return value will also be nil if the deleted element was nil itself.

Description

This function removes an element from an array and compresses the rest of the array to reduce its overall length by one. If the position is beyond the bounds of the array, nothing happens. This function is destructive.

Example

Gamma> a = [1,2,3,4,5];
[1 2 3 4 5]
Gamma> delete(a,3);
4
Gamma> a;
[1 2 3 5]
Gamma> 
		

See Also

insert