Skip to content

Instantly share code, notes, and snippets.

@revolucas
revolucas / print_table.lua
Last active April 16, 2024 15:13
[Lua] Print table function for deeply nested tables
--[[
Most pure lua print table functions I've seen have a problem with deep recursion and tend to cause a stack overflow when
going too deep. This print table function that I've written does not have this problem. It should also be capable of handling
really large tables due to the way it handles concatenation. In my personal usage of this function, it outputted 63k lines to
file in about a second.
The output also keeps lua syntax and the script can easily be modified for simple persistent storage by writing the output to
file if modified to allow only number, boolean, string and table data types to be formatted.
author: Alundaio (aka Revolucas)