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 | Constructs a list. |
lst_insert | Inserts elements to a specified position in a list. |
lst_append | Adds elements to the end of 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 | Obtains elements at specified positions from a list. |
lst_get | Obtains an element from a list or a tuple. |
op_len | Calculates the number of elements in a list or a tuple. |
lst_make
- Syntax
lst_make(Value 1, Value 2, ...)
- Parameters
Parameter Type Required Description Value 1 Arbitrary Yes The element in the list that you want to construct. Value 2 Arbitrary Yes The element in the list that you want to construct. - Response
The constructed list is returned.
- Example
Transformation rule:
e_set("hello", lst_make("k1","k2"))
Result:hello: ["k1","k2"]
lst_insert
- Syntax
lst_insert(List, Position, Value 1, Value 2, ...)
- Parameters
Parameter Type Required Description List List Yes The list to which you want to insert elements. Position Number Yes The position at which you want to insert the elements. Value 1 Arbitrary Yes The element that you want to insert. Value 2 Arbitrary No The element that you want to insert. - Response
The updated list is returned.
- Example
Raw log entry:
ctx: ["k1","k2"]
Transformation rule:e_set("hello", lst_insert(v("ctx"), 0, "k0"))
Result:ctx: ["k1","k2"] hello: ["k0", "k1", "k2"]
lst_append
- Syntax
lst_append(List, Value 1, Value 2, ...)
- Parameters
Parameter Type Required Description List List Yes The list to which you want to append elements. Value 1 Arbitrary Yes The element that you want to append. Value 2 Arbitrary No The element that you want to append. - Response
The updated list is returned.
- Example
Raw log entry:
ctx: ["k1","k2"]
Transformation rule:e_set("hello", lst_append(v(ctx), "k3"))
Result:ctx: ["k1","k2"] hello: ["k1", "k2", "k3"]
lst_delete_at
- Syntax
lst_delete_at(List, Position)
- Parameters
Parameter Type Required Description List list Yes The list from which you want to delete an element. Position Number Yes The position of the element that you want to delete. The position of the first element is 0. - Response
The updated list is returned.
- Example
Raw log entry:
ctx: ["k1","k2"]
Transformation rule:e_set("hello", lst_delete_at(v("ctx"),1))
Result:ctx: ["k1","k2"] hello: ["k1"]
lst_reverse
- Syntax
lst_reverse(List)
- Parameters
Parameter Type Required Description List List Yes The list in which you want to reverse the order of elements. - Response
The updated list is returned.
- Example
Raw log entry:
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 is used to obtain an element from a list or a tuple.
- Syntax
lst_get (List, Element index)
- Parameters
Parameter Type Required Description List List Yes The list from which you want to obtain an element. Element index Int Yes The index of the first element is 0. For example, the ["a","b","c"] list includes the elements a, b, and c. In this case, the corresponding element indexes are 0, 1, and 2. - Response
An element is returned.
- Example
""" Raw log entry: ctx: ["v1","v2"] Result: ctx: ["v1","v2"] hello: "v2" """ e_set("hello", lst_get(v("ctx"),1))