List
append
Description
The append() function creates a new list by concatenating the supplied arguments to the end of list1 in sequential order.
Syntax
result = append (list1, list-or-string1 [,list-or-string2, …]);
Arguments
list1 | Required. Contains the list to which the specified arguments are appended. |
list-or-string1 | Required. Contains either a character string or a list. This argument is appended to list1. |
list-or-string2 … | Optional. Contains additional character strings and/or lists. These additional arguments are appended to list1. |
Return values
The newly created list.
Example
TrustedUsers = {"JWhite", "TBrown", "SBlack"};
NewList = append (TrustedUsers, "RRoads");
In this example, result contains the following list:
{"JWhite", "TBrown", "SBlack", "RRoads"}
Example
List1 = {"JWhite", "TBrown"};
List2 = {"SBlack", "RRoads"};
NewList = append (List1, "RGreen", List2);
In this example, result contains:
{"JWhite", "TBrown", "RGreen", "SBlack", "RRoads"}
insert
Description
Returns a list constructed by inserting the strings or lists into a specific position (indicated by an integer index) in the specified list. Note that 0 is the start of the list, 1 is between the first and second elements in the list, and so on.
If you specify an index number that is larger than the specified list, then the strings are placed at the end of the list.
Syntax
result = insert (list, index, list-or-string1 [, list-or-string2, ...])
Arguments
list | Required. The original list. |
index | Required. The integer index. |
list-or-string1 | Required. The list or string to insert. |
list-or-string2 | Optional. The subsequent list(s) or string(s) to insert. |
Return values
A list.
Example
trustedusers={"jamie", "cory", "tom"};
a=insert(trustedusers, 1, "leslie");
The example above sets the following to the list:
{"jamie", "leslie", "cory", "tom"}
join
Description
The join() function creates a string by concatenating all of the elements in a list. The specified delimiter character separates each element in the generated string. If a delimiter character is not specified, then a blank is used as the delimiter.
Syntax
result = join (list [,delimiter]);
Arguments
list | Required. The list whose elements are to be concatenated into a new character string. |
delimiter | Optional. If specified, the delimiter character is used as a separator character between list elements as they are concatenated together. |
Return values
result Contains the new character string.
Example
TrustedUsers = {"Fred", "John", "George"};
NewString = join (Trustedusers, ",");
In this example, NewString contains the character string: Fred, John, George.
length
Description
The length() function returns the number of elements in the specified list. The index number for the first element in a list is always 0. The index number for the last list element is always the list length - 1.
Syntax
result = length (list1);
Arguments
list1 | Required. The list for which the number of elements is determined. |
Return values
result Contains the number of elements in list1.
Example
list1 = {"Fred", "George", "Sally"};
result = length (list1);
In this example, result contains the integer value 3.
range
Description
The range() function generates a new list from the elements in a list, starting at the element number that is specified by index1 and ending with the element number that is specified by index2.
The first element in a list always has an index value of 0. An index number that is larger then the last index in the list is treated as the last element. In the case where index1 is larger than the last index in the list, an empty list is returned (that is, with a list length equal to 0).
Syntax
result = range (list1, index1, index2);
Arguments
list1 | Required. The list from which a new list is extracted. |
index1 | Required. The element number, in list1, at which the extraction should begin. |
index2 | Required. The element number in list1 at which the extraction should end, inclusive. |
Return values
result Contains the new list that was extracted from list1.
Example
list1 = {"JWhite", "SBrown", "RRoads"};
result = range (list1, 1, 2);
In this example, result contains the following list:
{"SBrown", "RRoads"}
replace
Description
The replace() function replaces elements in a list, thereby creating a new list. The list elements in the specified range are deleted and those that are specified by the string arguments are inserted in their place. If replacement arguments are not supplied, then the appropriate elements are deleted without being replaced.
Syntax
result = replace (list1, index1, index2, list-or-string1 [, list-or-string2, ...]);
Arguments
list1 | Required. The list from which list elements are removed, and optionally, replaced by new elements. |
index1 | Required. The first element in the range of elements to delete or replace. |
index2 | Required. The last element in the range of elements to delete or replace. |
string1..n | Optional. The list(s) or character string(s) that will replace the list elements that are being deleted. |
Return values
result | Contains the new list that is created by deleting or replacing elements from the original list. |
Example
list1 = {"Adm1", "Adm2", "Adm3", "Adm4"};
result = replace (list1, 2, 3, "SysAdm1", "SysAdm2");
In this example, result contains the following list:
{"Adm1", "Adm2", "SysAdm1", "SysAdm2"}
search
Description
The search() function searches a list for the first element that is found to match a specific pattern. The search is case sensitive and wildcard characters can be used within the pattern.
Note
For more information on using wildcard characters, see Wildcard Search Characters and quote.
Syntax
result = search (list1, pattern);
Arguments
list1 | Required. The list to search. |
pattern | Required. The pattern to search for. |
Return values
An integer value is returned. If a match is found, then result contains the element number of the first pattern match in the list. If no match is found, result is set to -1.
Example
In this example,
list1 = {"ADM1", "ADM2", "ADM3", "SYSADM1", "SYSADM2", "USER1", "USER2"};
result = search (list1, "SYS*");
result is set to 3 as list1[3] is the first element in the list to match the search pattern.
See also
append(), insert(), join(), length(), range(), replace()
split
Description
The split() function creates a list from a string. The string is broken up into separate list elements based on the characters in the specified delimiter string. If a delimiter string is not specified, then a string containing space, tab (\t), and newline (\n) is used. If none of the delimiter characters are encountered, then a list that contains one element (that is, the entire string) is returned.
Syntax
result = split (string1[,delimiter[,omit_empty_elements]]);
Arguments
string1 | Required. The string to separate into list elements. |
delimiter | Optional. The delimiter string that is used to break the string into separate elements. If delimiter is not specified, then \t\n is used as the delimiter string. |
omit_empty_elements | Optional. Boolean value that determines whether empty elements of the resulting list are omitted (true) or included (false). If omit_empty_elements is not specified, it defaults to true. |
Return values
result contains the new list.
Example
UserList = "user1,user2,user3,,user4";
result = split (UserList,",");
In this example, result contains the following list:
{"user1", "user2", "user3", "user4"}
Example
UserList = "user1,user2,user3,,user4";
result = split (UserList,",",false);
In this example, result contains the following list:
{"user1", "user2", "user3", "", "user4"}
Updated 5 days ago