إنتقل إلى المحتوى الرئيسي

📋 Collection Operations

Module: array/* | Operators: 39

Work with lists and arrays including filtering, mapping, and aggregation.


Operator Reference

array/len

Length · 1 argument · returns number

Array length

ParameterTypeDescription
arrarrayThe array
["array/len", [1, 2, 3]] // => 3

array/empty?

Empty? · 1 argument · returns boolean

Check if array is empty

ParameterTypeDescription
arrarrayThe array
["array/empty?", []] // => true

array/first

First · 1 argument · returns any

Get first element

ParameterTypeDescription
arrarrayThe array
["array/first", [1, 2, 3]] // => 1

array/last

Last · 1 argument · returns any

Get last element

ParameterTypeDescription
arrarrayThe array
["array/last", [1, 2, 3]] // => 3

array/nth

Nth · 2 arguments · returns any

Get element at index

ParameterTypeDescription
arrarrayThe array
indexnumberIndex (0-based)
["array/nth", [1, 2, 3], 1] // => 2

array/slice

Slice · 2–3 arguments · returns array

Extract subarray

ParameterTypeDescription
arrarrayThe array
startnumberStart index
endnumberEnd index (exclusive)
["array/slice", [1, 2, 3, 4], 1, 3] // => [2, 3]

array/concat

Concat · 2 or more · returns array

Concatenate arrays

ParameterTypeDescription
...arrsarray[]Arrays to concatenate
["array/concat", [1, 2], [3, 4]] // => [1, 2, 3, 4]

array/append

Append · 2 arguments · returns array

Add item to end (returns new array)

ParameterTypeDescription
arrarrayThe array
itemanyItem to add
["array/append", [1, 2], 3] // => [1, 2, 3]

array/prepend

Prepend · 2 arguments · returns array

Add item to start (returns new array)

ParameterTypeDescription
arrarrayThe array
itemanyItem to add
["array/prepend", [2, 3], 1] // => [1, 2, 3]

array/insert

Insert · 3 arguments · returns array

Insert item at index (returns new array)

ParameterTypeDescription
arrarrayThe array
indexnumberIndex to insert at
itemanyItem to insert
["array/insert", [1, 3], 1, 2] // => [1, 2, 3]

array/remove

Remove · 2 arguments · returns array

Remove item at index (returns new array)

ParameterTypeDescription
arrarrayThe array
indexnumberIndex to remove
["array/remove", [1, 2, 3], 1] // => [1, 3]

array/removeItem

Remove Item · 2 arguments · returns array

Remove first matching item (returns new array)

ParameterTypeDescription
arrarrayThe array
itemanyItem to remove
["array/removeItem", [1, 2, 3, 2], 2] // => [1, 3, 2]

array/reverse

Reverse · 1 argument · returns array

Reverse array order (returns new array)

ParameterTypeDescription
arrarrayThe array
["array/reverse", [1, 2, 3]] // => [3, 2, 1]

array/sort

Sort · 1–3 arguments · returns array

Sort array (returns new array)

ParameterTypeDescription
arrarrayThe array
keystringField to sort by (for objects)
dirstring"asc" or "desc"
["array/sort", "@items", "price", "desc"]

array/shuffle

Shuffle · 1 argument · returns array

Randomly shuffle array (returns new array)

ParameterTypeDescription
arrarrayThe array
["array/shuffle", [1, 2, 3, 4, 5]]

array/unique

Unique · 1 argument · returns array

Remove duplicates (returns new array)

ParameterTypeDescription
arrarrayThe array
["array/unique", [1, 2, 2, 3, 1]] // => [1, 2, 3]

array/flatten

Flatten · 1 argument · returns array

Flatten nested arrays one level

ParameterTypeDescription
arrarrayThe array
["array/flatten", [[1, 2], [3, 4]]] // => [1, 2, 3, 4]

array/zip

Zip · 2 arguments · returns array

Pair elements from two arrays

ParameterTypeDescription
arr1arrayFirst array
arr2arraySecond array
["array/zip", [1, 2], ["a", "b"]] // => [[1, "a"], [2, "b"]]

array/includes

Includes · 2 arguments · returns boolean

Check if array contains item

ParameterTypeDescription
arrarrayThe array
itemanyItem to find
["array/includes", [1, 2, 3], 2] // => true

array/indexOf

Index Of · 2 arguments · returns number

Find index of item (-1 if not found)

ParameterTypeDescription
arrarrayThe array
itemanyItem to find
["array/indexOf", [1, 2, 3], 2] // => 1

array/find

Find · 2 arguments · returns any

Find first element matching predicate

ParameterTypeDescription
arrarrayThe array
predlambdaPredicate function
["array/find", "@items", ["fn", "x", ["=", "@x.status", "active"]]]

array/findIndex

Find Index · 2 arguments · returns number

Find index of first element matching predicate (-1 if none)

ParameterTypeDescription
arrarrayThe array
predlambdaPredicate function
["array/findIndex", "@items", ["fn", "x", ["=", "@x.status", "active"]]]

array/filter

Filter · 2 arguments · returns array

Keep elements matching predicate

ParameterTypeDescription
arrarrayThe array
predlambdaPredicate function
["array/filter", "@items", ["fn", "x", [">", "@x.price", 100]]]

array/reject

Reject · 2 arguments · returns array

Remove elements matching predicate

ParameterTypeDescription
arrarrayThe array
predlambdaPredicate function
["array/reject", "@items", ["fn", "x", ["=", "@x.status", "deleted"]]]

array/map

Map · 2 arguments · returns array

Transform each element

ParameterTypeDescription
arrarrayThe array
fnlambdaTransform function
["array/map", "@items", ["fn", "x", ["*", "@x.price", 1.1]]]

array/reduce

Reduce · 3 arguments · returns any

Reduce array to single value

ParameterTypeDescription
arrarrayThe array
fnlambdaReducer function (acc, item) => newAcc
initanyInitial accumulator value
["array/reduce", "@items", ["fn", ["acc", "x"], ["+", "@acc", "@x.price"]], 0]

array/every

Every · 2 arguments · returns boolean

Check if all elements match predicate

ParameterTypeDescription
arrarrayThe array
predlambdaPredicate function
["array/every", "@items", ["fn", "x", [">", "@x.price", 0]]]

array/some

Some · 2 arguments · returns boolean

Check if any element matches predicate

ParameterTypeDescription
arrarrayThe array
predlambdaPredicate function
["array/some", "@items", ["fn", "x", ["=", "@x.status", "active"]]]

array/count

Count · 1–2 arguments · returns number

Count elements (optionally matching predicate)

ParameterTypeDescription
arrarrayThe array
predlambdaPredicate function
["array/count", "@tasks", ["fn", "t", ["=", "@t.status", "done"]]]

array/sum

Sum · 1–2 arguments · returns number

Sum values (optionally by field)

ParameterTypeDescription
arrarrayThe array
keystringField to sum
["array/sum", "@cart.items", "price"]

array/avg

Avg · 1–2 arguments · returns number

Average of values (optionally by field)

ParameterTypeDescription
arrarrayThe array
keystringField to average
["array/avg", "@ratings", "score"]

array/min

Min · 1–2 arguments · returns number

Minimum value (optionally by field)

ParameterTypeDescription
arrarrayThe array
keystringField to compare
["array/min", "@products", "price"]

array/max

Max · 1–2 arguments · returns number

Maximum value (optionally by field)

ParameterTypeDescription
arrarrayThe array
keystringField to compare
["array/max", "@products", "price"]

array/groupBy

Group By · 2 arguments · returns any

Group elements by field value

ParameterTypeDescription
arrarrayThe array
keystringField to group by
["array/groupBy", "@orders", "status"]

array/partition

Partition · 2 arguments · returns array

Split array by predicate into [matches, nonMatches]

ParameterTypeDescription
arrarrayThe array
predlambdaPredicate function
["array/partition", "@items", ["fn", "x", [">", "@x.price", 50]]]

array/take

Take · 2 arguments · returns array

Take first n elements

ParameterTypeDescription
arrarrayThe array
nnumberNumber of elements
["array/take", "@items", 5]

array/drop

Drop · 2 arguments · returns array

Skip first n elements

ParameterTypeDescription
arrarrayThe array
nnumberNumber of elements to skip
["array/drop", "@items", 5]

array/takeLast

Take Last · 2 arguments · returns array

Take last n elements

ParameterTypeDescription
arrarrayThe array
nnumberNumber of elements
["array/takeLast", "@items", 3]

array/dropLast

Drop Last · 2 arguments · returns array

Skip last n elements

ParameterTypeDescription
arrarrayThe array
nnumberNumber of elements to skip
["array/dropLast", "@items", 2]