This topic describes the syntax and parameters of list functions. This topic also provides examples on how to use the functions.
Functions
Function | Description |
---|---|
lst_make | Creates a list. |
lst_insert | Inserts elements to a specified position in a list. |
lst_append | Appends elements to a list. |
lst_delete_at | Deletes the element at a specified position from a list. |
lst_reverse | Reverses the order of elements in a list. |
op_slice | Returns specific elements. |
lst_get | Returns the element at a specified position in a list or a tuple. |
op_len | 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"]
- Raw log
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"]
- Raw log
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"]
- Raw log
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"]
- Raw log
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"]
- Raw log
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"
- Raw log