Skip to content

Commit 133b150

Browse files
committed
feat(utils): add sets_equal function
1 parent 7ae211e commit 133b150

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/lua/utils.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,29 @@ function utils.get_game_state()
491491
}
492492
end
493493

494+
-- ==========================================================================
495+
-- Utility Functions
496+
-- ==========================================================================
497+
498+
function utils.sets_equal(list1, list2)
499+
if #list1 ~= #list2 then
500+
return false
501+
end
502+
503+
local set = {}
504+
for _, v in ipairs(list1) do
505+
set[v] = true
506+
end
507+
508+
for _, v in ipairs(list2) do
509+
if not set[v] then
510+
return false
511+
end
512+
end
513+
514+
return true
515+
end
516+
494517
-- ==========================================================================
495518
-- Debugging Utilities
496519
-- ==========================================================================

0 commit comments

Comments
 (0)