Skip to content
Jiowcl edited this page Jun 20, 2026 · 3 revisions

Table

Function Example Comment
table.sort table.sort(nums) In-place sorting; stable (equal elements are not transposed)
table.foreach table.foreach(t, f) Iterates through key-value pairs; f returns a non-nil value, ending early
table.map table.map(t, f) Returns a new array (each f(k,v) result)
table.filter table.filter(t, f) Returns a new table after filtering
table.reduce table.reduce(t, init, f) Collapses by f(acc, k, v)
table.find table.find(t, f) Returns the first matching key-value pair
table.index_of table.index_of(t, v) Searches for a value in an array segment, returning the index

Clone this wiki locally