Module : lang.table

Version : 0.4.0

Module Overview

This module provides lang library operations on table values defined by the language specification 2020R1.

Functions

add

Adds a member val to table t. It will be added as the last member. It panics if val has the same key as an existing member of t, or if val is inconsistent with the inherent type of t.

filter

Selects the members from a table for which a function returns true.

forEach

Applies a function to each member of a table. The func is applied to each member of t.

get

Returns the member of table t with key k. This for use in a case where it is known that the table has a specific key, and accordingly panics if t does not have a member with key k.

hasKey

Tests whether t has a member with key k.

iterator

Returns an iterator over a table. The iterator will iterate over the members of the table not the keys. The entries function can be used to iterate over the keys and members together. The keys function can be used to iterator over just the keys.

keys

Returns a list of all the keys of table t.

length

Returns number of members of a table.

map

Applies a function each member of a table and returns a table of the result. The resulting table will have the same keys as the argument table.

nextKey

Returns the next available integer key.

put

Adds a member val to table t, replacing any member with the same key value. If val replaces an existing member, it will have the same position in the order of the members as the existing member; otherwise, it will be added as the last member. It panics if val is inconsistent with the inherent type of t.

reduce

Combines the members of a table using a combining function. The combining function takes the combined value so far and a member of the table, and returns a new combined value.

remove

Removes a member of a table.

removeAll

Removes all members of a table. This panics if any member cannot be removed.

removeIfHasKey

Removes a member of a table with a given key, if the table has member with the key.

toArray

Returns a list of all the members of a table.