This topic describes the syntax and parameters of list functions. This topic also provides examples on how to use the functions.
Functions
Function | Description |
Creates a list. | |
Inserts elements to a specified position in a list. | |
Appends elements to a list. | |
Deletes the element at a specified position from a list. | |
Reverses the order of elements in a list. | |
Sorts a list. | |
Returns specific elements. | |
Returns the element at a specified position in a list or a tuple. | |
Calculates the number of elements in a list or a tuple. |
lst_make
The lst_make function creates a list.
Syntax
lst_make(value1, value2, ...)
Parameters
Parameter
Type
Required
Description
value1
String
Yes
The element of the list.
value2
String
Yes
The element of the list.
Response
The created list is returned.
Examples
Raw log
content:test
Transformation rule
e_set("hello", lst_make("k1","k2"))
Result
content:test hello:["k1", "k2"]
lst_insert
The lst_insert function inserts elements to a specified position in a list.
Syntax
lst_insert(list_string, location, value1, value2, ...)
Parameters
Parameter
Type
Required
Description
list_string
List
Yes
The input list.
location
Number
Yes
The position to which you want to insert elements.
value1
String
Yes
The element that you want to insert.
value2
String
No
The element that you want to insert.
Response
The list to which the elements are inserted is returned.
Examples
Raw log
ctx: ["k1","k2"]
Transformation rule
e_set("hello", lst_insert(v("ctx"), 0, "k0"))
Result
ctx: ["k1","k2"] hello: ["k0", "k1", "k2"]
lst_append
The lst_append function appends elements to a list.
Syntax
lst_append(list_string, value1, value2, ...)
Parameters
Parameter
Type
Required
Description
list_string
List
Yes
The input list.
value1
String
Yes
The element that you want to append.
value2
String
No
The element that you want to append.
Response
The list to which the elements are appended is returned.
Examples
Raw log
ctx: ["k1","k2"]
Transformation rule
e_set("hello", lst_append(v("ctx"), "k3"))
Result
ctx: ["k1","k2"] hello: ["k1", "k2", "k3"]
lst_delete_at
The lst_delete_at function deletes the element at a specified position from a list.
Syntax
lst_delete_at(list_string, location)
Parameters
Parameter
Type
Required
Description
list_string
list
Yes
The input list.
location
Number
Yes
The position of the element that you want to delete. The position of the first element is 0.
Response
The list from which the element is deleted is returned.
Examples
Raw log
ctx: ["k1","k2"]
Transformation rule
e_set("hello", lst_delete_at(v("ctx"),1))
Result
ctx: ["k1","k2"] hello: ["k1"]
lst_reverse
The lst_reverse function reverses the order of elements in a list.
Syntax
lst_reverse(list_string)
Parameters
Parameter
Type
Required
Description
list_string
List
Yes
The input list.
Response
The list whose order of elements is reversed is returned.
Examples
Raw log
ctx: ["v1","v2"]
Transformation rule
e_set("hello", lst_reverse(v("ctx")))
Result
ctx: ["v1","v2"] hello: ["v2","v1"]
lst_get
The lst_get function returns the element at a specified position in a list or a tuple.
Syntax
lst_get(list_string, location)
Parameters
Parameter
Type
Required
Description
list_string
List
Yes
The input list.
location
Int
Yes
The position of the element that you want to obtain. The position of the first element is 0. For example, if the input list is
["a","b","c"]
, you can obtain the elements at the following positions:0, 1, and 2
.Response
The element at the specified position is returned.
Examples
Raw log
ctx: ["v1","v2"]
Transformation rule
e_set("hello", lst_get(v("ctx"),1))
Result
ctx: ["v1","v2"] hello: v2
lst_sort
The lst_sort function sorts a list.
Syntax
lst_sort(value, reverse=False)
Parameters
Parameter
Type
Required
Description
value
List
Yes
The list that needs to be sorted.
reverse
Boolean
No
False (default): ascending order
True: descending order
Response
The sorted list is returned.
Examples
Example 1: Sort the ctx list in ascending order.
Raw log
ctx: ["1","2","5","3"]
Transformation rule
e_set("lst_sort", lst_sort(v("ctx")))
Result
ctx: ["1","2","5","3"] lst_sort:["1","2","3","5"]
Example 2: Sort the ctx list in descending order.
Raw log
ctx: ["1","2","5","3"]
Transformation rule
e_set("lst_sort", lst_sort(v("ctx"),reverse=True))
Result
ctx: ["1","2","5","3"] lst_sort:["5","3","2","1"]