Skip to content

Latest commit

 

History

History
255 lines (155 loc) · 3.36 KB

linq.md

File metadata and controls

255 lines (155 loc) · 3.36 KB

Language Integrated Query (LINQ)

Select(<array>, <delegate>)

Project data in a collection using delegates, the same way select clause in a SQL database to fetch specific columns of a table.

new_array = Select(array, ::delegate);

Foreach(<array>, <delegate>)

Executes a provided function for each array element.

Foreach(players, ::heal);

Aggregate(<initialValue>, <array>, <delegate>)

Aggregate the result of multiple delegate.

result = Aggregate(initialValue, array, ::delegate);

All(<array>, <predicate>)

Check if all items match the predicate.

isAll = All(array, ::predicate);

Where(<array>, <predicate>)

Reconstruct the array with only matches values from the predicate.

new_array = Where(array, ::predicate);

Any(<array>, <predicate>)

Check if atleast one item match the predicate.

isAny = Any(array, ::predicate);

Last(<array>, <predicate>)

Get the last item that match the predicate.

last = Last(array, ::predicate);

First(<array>, <predicate>)

Get the first item that match the predicate.

first = First(array, ::predicate);

Count(<array>, <predicate>)

Count all items that match the predicate.

count = Count(array, ::predicate);

Min(<array>)

Get the smallest value from an array of int/float/string/vector.

min = Min(array);

Max(<array>)

Get the biggest value from an array of int/float/string/vector.

max = Max(array);

Cast(<array>, <type>)

Reconstruct an array with all items casted to a specific type. Available types are: int, float, string.

strings = Cast(array, "string");
ints = Cast(array, "int");

OfType(<array>, <type>)

Reconstruct the array with only the specified type. Available types are: int, float, string.

strings = OfType(array, "string");
ints = OfType(array, "int");

Sort(<array>)

Sort all items from an array of int/float/string/vector.

new_array = Sort(array);

Average(<array>)

Get the average value from an array of int/float/vector.

average = Average(array);

Sum(<array>)

Adds all values from an array of int/float/vector/string.

sum = Sum(array);

Range(<array>, <min>, <max>)

Reconstruct the array with a specified range.

new_array = Range(array, 3, 6);

Repeat(<array>, <repeat>)

Repeat all values in an array.

new_array = Repeat(array, 3);

Reverse(<array>)

Reverse the array.

new_array = Reverse(array);

Concat(<arraySource>, <array>)

Concat an array with another array.

new_array = Concat(arraySource, array);

Chunk(<array>, <count>)

Split an array into multiple chunks.

chunks = Chunk(array, 5);

Contains(<array>, <count>)

Check if an array contains an element.

contains = Contains(array, 5);

IndexOf(<array>, <element>)

Get the index of an element.

index = IndexOf(array, 10);

Remove(<array>, <element>)

Remove an element from the array.

newArray = Remove(array, 10);

RemoveAt(<array>, <element>)

Remove an element from the array at a specific index.

newArray = RemoveAt(array, 1);