strlstlen

function strlstlen( lst ) --> len

Description

Receives a string list and returns the accumulated length of all strings.

Parameters

lst

An array table with strings.

Return Values

len

The accumulated length of all strings.

Code

--ZFUNC-strlstlen-v1
local function strlstlen( lst ) --> len
   local len = 0
   for _, str in ipairs( lst ) do
      len = len + string.len( str )
   end
   return len
end

return strlstlen

Examples

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

t( strlstlen{ "", "", "", "" }, 0 )
t( strlstlen{ "abc", "def", "", "gh" }, 8 )

t()