Skip to content

Array Operations

List manipulation — chunk, flatten, group, map, reduce, zip, and more.

12 modules

ModuleDescription
Chia mảngChia mảng thành các phần có kích thước chỉ định
CompactRemove null/empty values from array
Hiệu mảngTìm các phần tử trong mảng đầu tiên không có trong các mảng khác
DropDrop first N elements from array
Làm phẳng mảngLàm phẳng các mảng lồng nhau thành mảng đơn
Group ByGroup array elements by a key
Giao mảngTìm các phần tử chung giữa các mảng
Nối mảngNối các phần tử mảng thành chuỗi
Map mảngBiến đổi mỗi phần tử trong mảng
Reduce mảngRút gọn mảng thành giá trị đơn
TakeTake first N elements from array
Zip ArraysCombine multiple arrays element-wise

Modules

Chia mảng

array.chunk

Chia mảng thành các phần có kích thước chỉ định

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Array of items to process. Can be numbers, strings, or objects.
sizenumberYes10Number of items per chunk

Output:

FieldTypeDescription
resultarrayMảng các phần
chunksnumberMảng các phần

Example: Chunk into groups of 3

yaml
array: [1, 2, 3, 4, 5, 6, 7, 8, 9]
size: 3

Example: Batch process items

yaml
array: ["a", "b", "c", "d", "e"]
size: 2

Compact

array.compact

Remove null/empty values from array

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Array to compact
remove_empty_stringsbooleanNoTrueRemove empty strings
remove_zerobooleanNoFalseRemove empty strings
remove_falsebooleanNoFalseRemove zero values

Output:

FieldTypeDescription
resultarrayRemove false values
removednumberCompacted array

Hiệu mảng

array.difference

Tìm các phần tử trong mảng đầu tiên không có trong các mảng khác

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Array of items to process. Can be numbers, strings, or objects.
subtractarrayYes-Arrays containing items to remove from the base array

Output:

FieldTypeDescription
resultarrayCác phần tử duy nhất của mảng đầu tiên
lengthnumberCác phần tử duy nhất của mảng đầu tiên

Example: Find unique elements

yaml
array: [1, 2, 3, 4, 5]
subtract: [[2, 4], [5]]

Drop

array.drop

Drop first N elements from array

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Source array
countnumberYes1Source array

Output:

FieldTypeDescription
resultarrayNumber of elements to drop
droppednumberRemaining elements

Làm phẳng mảng

array.flatten

Làm phẳng các mảng lồng nhau thành mảng đơn

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Array of items to process. Can be numbers, strings, or objects.
depthnumberNo1How many levels of nesting to flatten (-1 for infinite)

Output:

FieldTypeDescription
resultarrayMảng đã làm phẳng
lengthnumberMảng đã làm phẳng

Example: Flatten one level

yaml
array: [[1, 2], [3, 4], [5, 6]]
depth: 1

Example: Flatten all levels

yaml
array: [[1, [2, [3, [4]]]]]
depth: -1

Group By

array.group_by

Group array elements by a key

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Array of objects to group
keystringYes-Array of objects to group

Output:

FieldTypeDescription
groupsobjectProperty name to group by
keysarrayGrouped results
countnumberGrouped results

Giao mảng

array.intersection

Tìm các phần tử chung giữa các mảng

Parameters:

NameTypeRequiredDefaultDescription
arraysarrayYes-Array of arrays to process (for intersection, union)

Output:

FieldTypeDescription
resultarrayCác phần tử chung
lengthnumberCác phần tử chung

Example: Find common elements

yaml
arrays: [[1, 2, 3, 4], [2, 3, 5], [2, 3, 6]]

Nối mảng

array.join

Nối các phần tử mảng thành chuỗi

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Array of items to process. Can be numbers, strings, or objects.
separatorselect (, , ,, , `
, , - `, ``)No,String to insert between items when joining

Output:

FieldTypeDescription
resultstringChuỗi đã nối

Example: Join with comma

yaml
array: ["apple", "banana", "cherry"]
separator: ,

Example: Join with newline

yaml
array: ["Line 1", "Line 2", "Line 3"]
separator:

Map mảng

array.map

Biến đổi mỗi phần tử trong mảng

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Array of items to process. Can be numbers, strings, or objects.
operationselect (multiply, add, subtract, divide, extract, uppercase, lowercase, trim, tostring, tonumber)Yes-Transformation to apply to each item
valueanyNo-Value for the operation: number for math operations, field name for extract

Output:

FieldTypeDescription
resultarrayMảng đã biến đổi
lengthnumberMảng đã biến đổi

Example: Multiply numbers

yaml
array: [1, 2, 3, 4, 5]
operation: multiply
value: 2

Example: Extract field from objects

yaml
array: [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]
operation: extract
value: name

Reduce mảng

array.reduce

Rút gọn mảng thành giá trị đơn

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Array of items to process. Can be numbers, strings, or objects.
operationselect (sum, product, average, min, max, count, join, first, last)Yes-How to combine all items into a single value
separatorselect (, , ,, , `
, , - `, ``)No,String to insert between items when joining

Output:

FieldTypeDescription
resultanyGiá trị đã rút gọn
operationstringGiá trị đã rút gọn

Example: Sum numbers

yaml
array: [1, 2, 3, 4, 5]
operation: sum

Example: Join strings

yaml
array: ["Hello", "World", "from", "Flyto"]
operation: join
separator:

Take

array.take

Take first N elements from array

Parameters:

NameTypeRequiredDefaultDescription
arrayarrayYes-Source array
countnumberYes1Source array

Output:

FieldTypeDescription
resultarrayNumber of elements to take
lengthnumberTaken elements

Zip Arrays

array.zip

Combine multiple arrays element-wise

Parameters:

NameTypeRequiredDefaultDescription
arraysarrayYes-Array of arrays to zip
fill_valueanyNo-Array of arrays to zip

Output:

FieldTypeDescription
resultarrayValue for missing elements
lengthnumberZipped array

Released under the Apache 2.0 License.