When you work with containers (list
,
map
, record
), you may use the
following functions:
list copy(
list arg, list arg)
;
The copy(list, list)
function accepts two
arguments, each of them is list. Elements of all lists must be of
the same data type. The function takes the second argument, adds
it to the end of the first list and returns the new resulting
list. Thus, the resulting list is a sum of both strings specified
as arguments. Remember that also the list specified as the first
argument changes to this new value.
boolean insert(
list arg, <numeric type>
position, <element type>
newelement1, ... ..., <element type>
newelementN)
;
The insert(list, <numeric type>, <element type>1, ...,
<element type>N)
function accepts the following arguments:
the first is a list, the second is of any numeric data type and
the others are of any data type, which is the same for all of
them. At the same time, this data type is equal to the that of the
list elements. The function takes the elements that are contained
in the function starting from the third argument (including the
third argument) and inserts them one after another to the list
starting from the position defined by the integer part of the
second argument. The list specified as the first argument changes
to this new value. The function returns true
if
it was successful, otherwise, it returns false
.
Remember that the list element are indexed starting from 0.
<element type> poll(
list arg)
;
The poll(list)
function accepts one
argument of list data type. It takes this argument, removes the
first element from the list and returns this element. Remember
that the list specified as the argument changes to this new value
(without the removed first element).
<element type> pop(
list arg)
;
The pop(list)
function accepts one
argument of list data type. It takes this argument, removes the
last element from the list and returns this element. Remember that
the list specified as the argument changes to this new value
(without the removed last element).
boolean push(
list arg, <element type>
list_element)
;
The push(list, <element type>)
function
accepts two arguments: the first is list and the second is of any
data type. However, the second argument must be of the same data
type as each element of the list. The function takes the second
argument and adds it to the end of the first argument. Remember
that the list specified as the first argument changes to this new
value. The function returns true
if it was
successful, otherwise, it returns false
.
list remove(
list arg, <numeric type>
position)
;
The remove(list, <numeric type>)
function
accepts two arguments: the first is list and the second is of any
numeric data type. The function takes the integer part of the
second argument and removes the list element at the specified
position. Remember that the list specified as the first argument
changes to this new value (without the removed element). And note
that the function returns this new list. Remember that the list
elements are indexed starting from 0.
boolean remove_all(
list arg)
;
The remove_all(list)
function accepts one
list argument. The function takes this argument and empties the
list. It returns a boolean value. Remember that the list specified
as the argument changes to the empty list.
list reverse(
list arg)
;
The reverse(list)
function accepts one
argument of list data type. It takes this argument, reverses the
order of elements of the list and returns such new list. Remember
that the list specified as the argument changes to this new
value.
list sort(
list arg)
;
The sort(list)
function accepts one
argument of list data type. It takes this argument, sorts the
elements of the list in ascending order according to their values
and returns such new list. Remember that the list specified as the
argument changes to this new value.