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( "tapered" )
local snakecase = require( "snakecase" )

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

t.done()

Inspired by

See also