From 82966e99c367fe0e94b1d6ea49260d7148090315 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Sun, 26 Sep 2021 20:12:38 -0400 Subject: [PATCH] Added two more utility functions --- funcs.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/funcs.lua b/funcs.lua index 70697f3..98d6835 100644 --- a/funcs.lua +++ b/funcs.lua @@ -97,6 +97,22 @@ function table.contains(table, element) return false end +function table.keys(table) + local target = {} + for key in pairs(table) do + target[#target+1] = key + end + return target +end + +function table.numkeys(table) + local count = 0 + for k in pairs(table) do + count = count + 1 + end + return count +end + function clamp(x, min, max) if max < min then min, max = max, min