GlyEngine 0.0.17
Create games and apps with lua
Loading...
Searching...
No Matches
Array

Functions

local function map (array, func)
 std.array.map
 
local function filter (array, func)
 std.array.filter
 
local function unique (array)
 std.array.unique
 
local function each (array, func)
 std.array.each
 
local function reducer (array, func, value)
 std.array.reducer
 
local function index (array, func, reverse)
 std.array.index
 
local function first (array, func)
 std.array.first
 
local function some (array, func, reverse)
 std.array.some
 
local function every (array, func)
 std.array.every
 
local function compare (array, func)
 std.array.compare
 

Detailed Description

Todo
more examples in std.array

Pipeline

get the final array with :array() or :json()
local original_array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
local modified_array = std.array.from(original_array)
:filter(function(value) return value % 2 == 0 end)
:map(function(value) return value * 2 end)
:unique()
:table()
local function map(array, func)
std.array.map
local function filter(array, func)
std.array.filter
local function unique(array)
std.array.unique

Function Documentation

◆ compare()

local function compare ( array ,
func  )

compares the value of A with B, and B with C and so on, and checks if they are all true

Parameters
[in]array
[in]func
Returns
boolean
local array = {1, 2, 3, 4, 5, 6}
local same_type = std.array.compare(array, function(val1, val2) return type(val1) == type(val2) end)
local order_is_asc = std.array.compare(array, function(val1, val2) return val1 < val2 end)
local order_is_desc = std.array.compare(array, function(val1, val2) return val1 > val2 end)

◆ each()

local function each ( array ,
func  )
Parameters
[in]array
[in]func

◆ every()

local function every ( array ,
func  )
Parameters
[in]array
[in]func
Returns
boolean

◆ filter()

local function filter ( array ,
func  )
Parameters
[in]array
[in]func
Returns
new array

◆ first()

local function first ( array ,
func  )

std.array.last

Parameters
[in]array
[in]func
Returns
value from array

◆ index()

local function index ( array ,
func ,
reverse  )
Parameters
[in]array
[in]func
Returns
index of array

◆ map()

local function map ( array ,
func  )
Parameters
[in]array
[in]func
Returns
new array

◆ reducer()

local function reducer ( array ,
func ,
value  )
Parameters
[in]array
[in]func
Returns
some value

◆ some()

local function some ( array ,
func ,
reverse  )
Parameters
[in]array
[in]func
Returns
boolean

◆ unique()

local function unique ( array )
Parameters
[in]array
Returns
new array