summaryrefslogtreecommitdiffstats
path: root/acf2/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'acf2/util.lua')
-rw-r--r--acf2/util.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/acf2/util.lua b/acf2/util.lua
index 25e885b..a40f7fd 100644
--- a/acf2/util.lua
+++ b/acf2/util.lua
@@ -71,6 +71,15 @@ function M.keys(tbl)
return res
end
+--- determine whether a value is present in an array.
+-- @param list an array
+-- @param value a value
+-- @return a boolean
+function M.contains(list, value)
+ for k, v in ipairs(list) do if v == value then return true end end
+ return false
+end
+
--- map a function over a table.
-- @param func a function with one argument
-- @param tbl the table