ADD gmatch to table function

This commit is contained in:
Nathan Dwarshuis 2022-07-23 19:54:49 -04:00
parent c27dfa0c0a
commit 62008e7eb7
1 changed files with 10 additions and 0 deletions

View File

@ -2,7 +2,9 @@ local M = {}
local err = require 'err' local err = require 'err'
local __string_gmatch = string.gmatch
local __math_floor = math.floor local __math_floor = math.floor
local __table_insert = table.insert
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- zippy functions -- zippy functions
@ -175,6 +177,14 @@ M.table_array = function(tbl)
return r return r
end end
M.gmatch_table = function(pat, s)
local r = {}
for m in __string_gmatch(s, pat) do
__table_insert(r, m)
end
return r
end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- functional functions -- functional functions