forked from zeng-github01/OC-Doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransforms.lua
More file actions
49 lines (42 loc) · 1.73 KB
/
transforms.lua
File metadata and controls
49 lines (42 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---@meta
--- OpenComputers Transforms API
---
--- Provides utilities for working with indexed tables (sequences).
---@class TransformsLib
local transforms = {}
--- Returns a sub-table from first to last (inclusive).
---@param tbl table Source table
---@param first number Start index
---@param last number? End index (optional)
---@return table Sub-table
function transforms.sub(tbl, first, last) end
--- Returns the first index where predicate is satisfied.
---@param tbl table Source table
---@param predicate function|table Predicate function or table
---@param first number? Start index (optional)
---@param last number? End index (optional)
---@return number startIndex
---@return number endIndex
function transforms.first(tbl, predicate, first, last) end
--- Partitions the table into sublists using the partitioner predicate.
---@param tbl table Source table
---@param partitioner function Predicate function
---@param first number? Start index (optional)
---@param last number? End index (optional)
---@return table[] List of sub-tables
function transforms.partition(tbl, partitioner, first, last) end
--- Returns true if the sub-table matches at the start of tbl.
---@param tbl table Source table
---@param sub table Sub-table to match
---@param first number? Start index (optional)
---@param last number? End index (optional)
---@return boolean True if begins with sub
function transforms.begins(tbl, sub, first, last) end
--- Applies adapter to each element, returns adapted table.
---@param tbl table Source table
---@param adapter function Adapter function
---@param first number? Start index (optional)
---@param last number? End index (optional)
---@return table Adapted table
function transforms.foreach(tbl, adapter, first, last) end
return transforms