-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gen: propagate luafun iterators [TO SQUASH]
- Loading branch information
Showing
2 changed files
with
37 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Returns a new table, recursively copied from the one given. | ||
-- | ||
-- @param table table to be copied | ||
-- @return table | ||
local function tbl_copy(orig) | ||
local orig_type = type(orig) | ||
local copy | ||
if orig_type == "table" then | ||
copy = {} | ||
for orig_key, orig_value in next, orig, nil do | ||
copy[tbl_copy(orig_key)] = tbl_copy(orig_value) | ||
end | ||
-- number, string, boolean, etc. | ||
else | ||
copy = orig | ||
end | ||
return copy | ||
end | ||
|
||
return { | ||
copy = tbl_copy, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters