12.6 Inserting and Deleting Elements

The push () function allows to insert new elements into an array.

Added in G-Cows version 1.3

12.6.1 Synopsis

push (array [ ], element)
push (array [ ], element, index )

12.6.2 Description

The former syntax adds element at the end of array [ ]. The latter inserts element at position index and shifts other elements.

Important: array is left unchanged so if you want to insert an element into a given array you must replace it with the new array returned by push ():

foo [ ] = push (foo[ ], "New Element");

To remove elements from an arry you can use the delete () function.

Added in G-Cows version 1.3

12.6.3 Synopsis

delete (array [ ], index)
delete (array [ ], index, number)

12.6.4 Description

The former syntax returns array [ ] whith the element at position index removed. The latter removes number elements starting from index.

Important: array is left unchanged so if you want to remove an element from a given array you must replace it with the new array returned by delete ():

foo [ ] = delete (foo[ ], 12, 4);

This manual can be downloaded from http://www.g-cows.org/.