Function & Argument Type(s)
|
Description
|
Example
|
newAray(integer number of indices, token) | Creates
an array with the number of indices and the token value. All
positions will have the same token value. The token can be of any
type including Data Structure. If using Data Structure template name,
this must be enclosed in "". |
>> x = newArray (4, {1,2,3}) {{1, 2, 3} , {1, 2, 3} , {1, 2, 3} , {1, 2, 3} } >> x = newArray(4,"Processor_DS") >>x = newArray(5,"str") |
Array Usage |
Array(i) = Array(j) - Y + Z where Y and Z can reference a Array location, parameters, Variables. The data types can be scalar, boolean or string data types. The indices i and j, must be a integer type and can be a value, memory, parameter or field. Array(i)(j) = Array(i)(j) + Y + Z This is definition for a multi-dimension array. The indices i and j, must be integer and can be a value, memory, parameter or field. |
|
Initialize Array Format |
The same formar can be used in initializing a memory and in the Data Structure template file. |
Scalar: Array1 local {1,2,3} Data Structure: Array1 local {10:Processor_DS} Multi-Array: Array1 global {10:{10:Processor_DS}} Note: Use the same format for Above can be used for defining in Data Structure text file also. |
Math Operations +, -, *, /, % (Modulo) |
Use the standard math operator on Arrays. Types are int, double and long |
>> a = {1,2,3,4} |
abs() |
Find absolute of each array element. Types are int, double and long |
1D Array = {1,-2,-3,4} X=Array.abs() = {1,2,3,4} 2D Array = {{1,-5,6},{-3,5,10}} X=Array(1).abs() = {3,5,10} |
append (value1) |
Returns an array with one value appended. Value1 can be of any type. Fast append function. |
Array = {1,2,3} X=Array.append(10) = {1,2,3,10} |
clear() |
Clear array elements to zero, if int, long, or double. |
1D Array = {1,2,3,4} Array=Array.clear() = {0,0,0,0} 2D Array = {{1,2,3},{4,5}} Array1= (Array(1)).clear = {0,0} |
concatenate (Array) |
Merge a 2D-array into a 1D-array. |
Array = {{1,2,3,4},{6,7}} Array=concatenate(Array) = {1,2,3,4,6,7} |
concatenate (Array1,Array2) |
Concatenate two arrays and return a single array. Two arrays of size 4 will return an array of size 8. |
Array1 = {1,2,3} Array2 = {4,5} Array = concatenate(Array1,Array2) = {1,2,3,4,5} |
common (Array) |
Scalar: Compares the first Array with the list in (Array) and outputs a list of values that match. Data Structure: When searching an array of data structures, it will find the data structure that contains all the matching fields from the Array to be matched and return that data structure. |
Scalar Array = {1,2,3,4,5} Array2 = {1,1,5} Common_Array = Array.common(Array2) = {1, 5} Data Structure |
commonIndex (Array) |
Scalar: Compares the first Array with the list in the second Array and outputs a list of indices that match. Data Structure: When searching an array of data structures, it will find the INDEX of the data structure that contains all the matching fields from the Array to be matched and return that INDEX. |
Scalar: Array = {100,200,300,400} Array2 = {100,400} Common= Array.commonIndex(Array2) = {0, 3} Data Structure: >> MyArray = {{a=1,b=2},{a=2,b=3},{a=3,b=4}} |
extract (Array) |
Extract a non-contiguous subarray either by giving a boolean array of the same length of this array describing which elements to include, or by giving an array of an arbitrary length with the indices of elements to include. |
Array ={false,true,false,false,true} X= Array.extract ({true,true,false,false,true}) Or X=Array.extract({1,2}) = {true,false} |
find (Array) |
Find all true-valued elements in an array of boolean values, returning an array containing the indices (in ascending order) of all occurrences of the value 'true'. |
1D A1 = {false,true,false,false,true} X=find(A1) = {1,4} 2D A2 ={{true,false},{false,true}} X=find(Array(1)) = {1} |
find (Array array, Token) |
Find all elements in an array that match the specified token and return an array containing their indices (in ascending order). The token can be a string, boolean, integer, double or long. |
1D Array = {1,2,3,4,2,6,7} X=find(Array,2) = {1,4} 2D Array = {{1,2,3,4},{2,4,2}} X=find(Array(1), 2) = {0,2} |
find (Array array, Token, Integer lastIndex) |
Find all elements in an array that match the specified token and return an array containing their indices (in ascending order). The search starts from the lastIndex position in the array. The token can be a string, boolean, integer, double or long. Returns an empty array if none are found |
A1 = {false,true,false,true,false} X=find(A1,false,2) = {2,4} |
findCircular (Array array, Token, Integer lastIndex) |
Find all elements in an array that match the specified token and return an array containing their indices (in ascending order). The search starts from the lastIndex position in the array and continues from the beginning of the array in a loop. The token can be a string, boolean, integer, double or long. Returns an empty array if none are found |
A1 = {false,true,false,true,false} X=findCircular(A1,false,2) = {2,4,0} |
removeHead() |
Returns the token without the |
Array = {11,12,13,14,15,16} Tail_Token = Array.removeHead() = {12,13,14,15,16} |
removeTail() |
Returns the token in the |
Array = {11,12,13,14,15,16} Head_Token = Array.removeTail() = {11,12,13,14,15} |
firstGreaterThanZero |
Returns first index of |
1D Array = {1,2,-3,-1,0,6} X = Array.firstGreaterThanZero(2) = 5 2D Array = {{1,2,-3,0},{-1,0,-3,1}} X=(Array(1)).firstGreaterThanZero(0) = 3 |
decrementArrayArrayElement |
Decrement an array of |
A1 = {{1,2,3,4},{2,5,6}} X=A1.decrementArrayArrayElement(1, 1) = 4 |
getArrayArrayElement |
Get an array of |
Array = {{1,2,3,4},{2,5,6}} X= Array.getArrayArrayElement(1, 1) = 5 Alternate Method (Slower): X = Array(1)(1) |
putArrayArrayElement |
Put an array element of |
Array = {{1,2,3,4},{2,5,6}} X = Array.putArrayArrayElement(0,0,9) = 9 |
incrementArrayArrayElement |
Increment an element of a 2D array with index (index, index2). |
Array = {{1,2,3,4},{2,5,6}} X=Array.incrementArrayArrayElement(0, 0) =2 |
isGreaterThan |
Returns an array of all the indices that have a value greater than the token. The token can be an integer or double. |
1D Array = {-2,0,3,6,-4} X=Array.isGreaterThan(1) ={2,3} 2D Array = {{-2,0,3,-7},{2,-5,7}} X=(Array(0)).isGreaterThan(1) = {2} |
isLessAndGreaterThan (Token t1, Token t2) |
Returns an array of all the indices that are simultaneously greater than “t1” and less than “t2”. The tokens can be an integer or double. |
1D Array = {1,2,3,4,5} X=Array.isLessAndGreaterThan(3,1) = {1} 2D Array = {{1,2,3,4,5},{2,5,7,3}} X=(Array(1)).isLessAndGreaterThan(4,1) = {0,3} |
isLessThan (Token) |
Returns an array of all the indices that have a value less than the token. The token can be an integer or double. |
1D Array = {-3,0,5,6,-1} X = Array.isLessThan(1) = {0, 1, 4} 2D Array = {{-2,0,7,-3},{1,3,0}} X = (Array(0)).isLessThan(1) = {0, 1, 3} |
Array.insert (Token token, int index) |
Places the token value in the index location and outputs a new array |
Array = {1,2,3,4,5} X=Array.insert(8,1) ={1,8,2,3,4,5} |
isEmpty() |
Return true if the arrya is empty. |
Array = {} X=Array.isEmpty() =true |
length() |
Return the length of the contained token array. |
Array = {1,2,3,4,5} X=Array.length() = 5 |
max() |
Find maximum of array elements. |
1D Array = {1,2,3,8,4,1} X = Array.max() = 8 2D Array = {{1,2,6,3},{9,1,4}} X = (Array(0)).max() = 6 |
maxi() |
Find the index to the maximum value in the array. |
1D Array = {1,2,3,8,4,1} X = Array.maxi() = 3 2D Array = {{1,2,6,3},{9,1,4}} X = (Array(1)).maxi() = 0 |
maxi(3) integer |
User can obtain the index of the maximum value by using the maxi() function, which returns the maximum index starting from variable index for searching the maximum value. |
MyArray = {1,3,3,3,2} MyMaxIndex = MyArray.maxi(3) =3 |
randi() |
Return a random index |
Array = {1,2,3} X=Array.randi() = 0 |
mean() |
Find mean of array elements. |
1D Array = {1,2,3,8,4} X = Array.mean() = 3.6 2D Array = {{1,2,6,3},{9,2,4}} X = (Array(0)).mean() = 3.0 |
min() |
Find minimum array element. |
1D Array = {1,2,3,8,4} X = Array.min() = 1 2D Array = {{1,2,6,3},{9,2,4}} X = (Array(1)).min() = 2 |
mini() |
Find the index to the minimum value in array. |
1D Array = {1,2,3,8,4} X = Array.mini() = 0 2D Array = {{1,2,6,3},{9,2,4}} X = (Array(1)).mini() = 1 |
mini(4) |
Find the index to the minimum value in array from the starting index. |
Array = {1,3,3,3,1} MaxIndex = Array.mini(4) = 4 |
one() |
Return a new ArrayToken representing the multiplicative identity. |
Array = {1,2,3,4,5} X = Array.one() = {1,1,1,1,1} |
take() (int index) |
Remove the array element at the index and return this value to the LHS. If index out of range return current array. If one element in the array then return an empty array. |
1D: Array = {1,2,3,4,5} X = Array.take(2) = 3 2D: Array = {{1,2,6,3},{9,2,4}} X=Array(1).take(2) = 4 |
Array.search |
Fast Search. Search an array that matches the match_token. If there is no match, it returns -1. This function searches until the end of the array. |
Array = {1,2,3,4,5} Index = Array.search(1) = 0 Index = Array.search(6) = -1 |
Array.search (Token, int Starting_Index) |
Fast Search. Search an array from the starting index, and return the first index that matches |
Array = {1,2,3,4,5} Index = Array.search(1, 0) = 0 Index = Array.search(6, 4) = -1 |
Array.searchCircular (Token, int Starting_Index) |
Fast Search. Returns the index to the first matching value from the starting Index to the end and continues from the beginning. If there is no match, it returns -1. |
Array = {1,2,3,4,5} X=Array.search(1, 2) =0 |
search(Array, match_token) |
Fast Search. Search an array that matches the match_token. If there is no match, it returns -1. This function searches until the end of the array. |
Array = {1,2,3,4,5} Index = search(Array, 1) = 0 Index = search(Array, 6) = -1 |
search (Array, Token, int Starting_Index) |
Returns the index to the first matching value from the starting Index. If there is no match, it returns -1. |
Array = {1,2,3,4,5} X=search(Array, 1, 2) =-1 |
searchCircular (Array, Token, int Starting_Index) |
Returns the index to the first matching value from the starting Index to the end and continues from the beginning. If there is no match, it returns -1. |
Array = {1,2,3,4,5} X=search(Array, 1, 2) =0 |
sort() |
Sort the array min to max. |
Array = {5,8,7,6,9,3,2,1} Array = Array.sort() = {1,2,3,5,6,7,8,9} |
stdev() |
Find standard deviation of array elements. |
1D: Array = {5,8,7,6,9,3,2,1} X = Array.stdev() = 2.7128168017763 2D: Array = {{1,2,6,3},{9,2,4}} X = (Array(0)).stdev() = 1.870828693387 |
subarray (int index, int count) |
Return the contiguous subarray starting at the specified index and of the specified length. If the length of the Array < count, then returned array will be smaller. |
Array = {5,8,7,6,9,3,2,1} X = Array.subarray(1,12) = {8, 7, 6, 9, 3, 2, 1} |
subarray (Array array, Integer index, Integer count) |
Return the contiguous subarray of the specified array starting at the specified index and of the specified length. If the length of the Array < count, then returned array will be smaller. |
Array = {5,8,7,6,9,3,2,1} X = subarray(Array,1,12) = {8, 7, 6, 9, 3, 2, 1} |
sum() |
Sum array elements. |
Array = {1,2,3,4,5} X=Array.sum() = 15 |
Array.removeElement (int index) |
Remove the array element at the index in the array and returns the array with remaining elements to the LHS. |
1D: Array = {1,2,3,4,5} X = Array.removeElement(4) = {1,2,3,4} 2D: Array = {{1,2,6,3},{9,2,4}} X=Array(1).removeElement(2) = {9,2} |
toString() |
Return the value of this token as a string that can be parsed by the expression language to recover a token with the same value. |
Array = {1,2,3,"str1","str2"} X = Array.toString() = "{"1","2","3","str1","str2"}" |
$VS\VS_AR\doc\Training_Material\General\RegEx\RegEx_Array_Test01.xml
$VS\VS_AR\doc\Training_Material\General\RegEx\RegEx_Array_Test02.xml
$VS\VS_AR\doc\Training_Material\General\RegEx\RegEx_Array_Test03.xml
Created with the Personal Edition of HelpNDoc: Easily create Help documents