buildset
function buildset( arr ) --> res
Description
Creates a set with the values in the array table arr as indices. All values in the set are true.
Parameters
- arr
-
An array table with the indices of the set.
Return Values
- res
-
A dictionary table where all existing values are true.
Code
--ZFUNC-buildset-v1 local function buildset( arr ) local res = {} for _, v in ipairs( arr ) do res[ v ] = true end return res end return buildset
Examples
local t = require( "taptest" ) local buildset = require( "buildset" ) keywords = buildset{ "while", "end", "function", "local" } t( keywords[ "function" ], true ) t( keywords[ "class" ], nil ) t()