snakecase

function snakecase( strlst ) --> str

Description

Concatenate the assigned words in the array table to a snake case string.

Parameters

strlst

An array table with strings.

Return Values

str

The generated snake case string.

Code

--ZFUNC-snakecase-v1
local function snakecase( strlst ) --> str
   local str = {}
   for i, v in ipairs( strlst ) do
      table.insert( str, string.lower( v ) )
   end
   return table.concat( str, "_" )
end

return snakecase

Examples

local t = require( "taptest" )
local snakecase = require( "snakecase" )

t( snakecase{ "Wiki", "Word", "BUMPY", "caPS" }, "wiki_word_bumpy_caps" )

t()

Inspired by

See also