ownown

helpers.lua

Jan 30th, 2022
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. -- Helper functions
  3.  
  4. -- Create a set where membership can be checked by set_name[potential_member]
  5. function Set (array)
  6.     local set = {}
  7.     for _, l in ipairs(array) do
  8.         set[l] = true
  9.     end
  10.     return set
  11. end
  12.  
  13. -- Get the length of an array
  14. function Length(array)
  15.     local count = 0
  16.     for _, l in ipairs(array) do
  17.         count  = count + 1
  18.     end
  19.     return count
  20. end
  21.  
Advertisement
Add Comment
Please, Sign In to add comment