Little refactoring
This commit is contained in:
parent
d2308917b4
commit
8a8db93ac1
7 changed files with 67 additions and 53 deletions
30
config.lua
30
config.lua
|
|
@ -1,3 +1,5 @@
|
|||
require 'tablefuncs'
|
||||
|
||||
-- Global config table
|
||||
---@class Config
|
||||
---@field pointRadius number Radius of each grid point
|
||||
|
|
@ -27,31 +29,3 @@ Color = {
|
|||
green = { 0, 1, 0 },
|
||||
blue = { 0, 0, 1 }
|
||||
}
|
||||
|
||||
-- Find key by value in table by predicate
|
||||
---@param table table
|
||||
---@param value any
|
||||
---@param pred function
|
||||
---@return any
|
||||
function TableFind( table, value, pred )
|
||||
for key, innervalue in pairs( table ) do
|
||||
if pred( value, innervalue ) then
|
||||
return key
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Find if value exists in table by predicate
|
||||
---@param table table
|
||||
---@param value any
|
||||
---@param pred function
|
||||
---@return boolean
|
||||
function TableHas( table, value, pred )
|
||||
for _, innervalue in pairs( table ) do
|
||||
if pred( value, innervalue ) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue